text-download / text_download.py
m-ric's picture
m-ric HF staff
Update text_download.py
8ac8a9e verified
raw
history blame
529 Bytes
import requests
from bs4 import BeautifulSoup
from transformers.tools.base import Tool
TEXT_DOWNLOAD_DESCRIPTION = (
"This is a tool that downloads a file from a `url`. It takes the `url` as input, and returns the text"
" contained in the file."
)
class TextDownloadTool(Tool):
name = "text_downloader"
inputs= {"url": str}
output_type= str
description = TEXT_DOWNLOAD_DESCRIPTION
def __call__(self, url):
return BeautifulSoup(requests.get(url).text, features="html.parser").get_text()