Spaces:
Sleeping
Sleeping
Download scrap_post.py from Jobanpreet/LinkedInpost: direct link, hf CLI and curl.
- Browser
- Download file 388 Bytes
-
https://huggingface.co/spaces/Jobanpreet/LinkedInpost/resolve/main/scrap_post.py
- Command line
-
hf download hf://spaces/Jobanpreet/LinkedInpost/scrap_post.py
-
curl -L -o scrap_post.py https://huggingface.co/spaces/Jobanpreet/LinkedInpost/resolve/main/scrap_post.py
388 Bytes
| import requests | |
| import json | |
| from bs4 import BeautifulSoup | |
| def scrappost(url): | |
| response = requests.get(url) | |
| soup = BeautifulSoup(response.text, 'html.parser') | |
| span_tags = soup.find_all('script',type="application/ld+json") | |
| content_list = [tag.get_text() for tag in span_tags] | |
| for content in content_list: | |
| data=json.loads(content)['articleBody'] | |
| return data |