source-code-retriever-tool / source_code_retriever.py
Pierre Lepagnol
App init
e32fc13
raw
history blame contribute delete
No virus
521 Bytes
import requests
from bs4 import BeautifulSoup
from transformers import Tool
class ScrapperTool(Tool):
name = "source_code_scrapper"
description = (
"This is a tool that retrieves the source code of a given webpage. "
"It takes the URL of the webpage, and returns the source code."
)
inputs = ["text"]
outputs = ["text"]
def __call__(self, url: str):
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
return soup.prettify()