Spaces:
Runtime error
Runtime error
Download text_download.py from huggingface-tools/text-download: direct link, hf CLI and curl.
- Browser
- Download file 551 Bytes
-
https://huggingface.co/spaces/huggingface-tools/text-download/resolve/main/text_download.py
- Command line
-
hf download hf://spaces/huggingface-tools/text-download/text_download.py
-
curl -L -o text_download.py https://huggingface.co/spaces/huggingface-tools/text-download/resolve/main/text_download.py
551 Bytes
| import requests | |
| from bs4 import BeautifulSoup | |
| from transformers.agents import Tool | |
| TEXT_DOWNLOAD_DESCRIPTION = ( | |
| "This is a tool that downloads a file from a `url` and returns the text contained in the tile." | |
| ) | |
| class TextDownloadTool(Tool): | |
| name = "text_downloader" | |
| inputs= {"url": {"type": "string", "description": "url to download file from"}} | |
| output_type= "string" | |
| description = TEXT_DOWNLOAD_DESCRIPTION | |
| def forward(self, url): | |
| return BeautifulSoup(requests.get(url).text, features="html.parser").get_text() | |