Spaces:
Sleeping
Sleeping
Download utils/read_web.py from firefighter/PdfSumGPT: direct link, hf CLI and curl.
- Browser
- Download file 386 Bytes
-
https://huggingface.co/spaces/firefighter/PdfSumGPT/resolve/refs%2Fpr%2F1/utils/read_web.py
- Command line
-
hf download hf://spaces/firefighter/PdfSumGPT@refs/pr/1/utils/read_web.py
-
curl -L -o read_web.py https://huggingface.co/spaces/firefighter/PdfSumGPT/resolve/refs%2Fpr%2F1/utils/read_web.py
386 Bytes
| import re | |
| import requests | |
| from bs4 import BeautifulSoup | |
| def read_web(url: str) -> str: | |
| if not url: | |
| return '' | |
| resp = requests.get(url) | |
| soup = BeautifulSoup(resp.text, 'html.parser') | |
| text = soup.get_text() | |
| text = re.sub('\n{3,}', '\n\n', text) | |
| return text | |
| if __name__ == '__main__': | |
| r = read_web('https://en.wikipedia.org/wiki/Wiki') | |
| print(r) | |