File size: 521 Bytes
e32fc13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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()