Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
fix: remover bug
PeriniMeacda97a1c34
diff --git a/.gitignore b/.gitignoreindex 7a9e89dc..45159e0c 100644--- a/.gitignore+++ b/.gitignore@@ -20,3 +20,4 @@ docs/source/_templates/docs/source/_static/.envvenv/+.vscode/diff --git a/examples/html_scraping.py b/examples/html_scraping.pyindex c19ba9cb..d9d75c64 100644--- a/examples/html_scraping.py+++ b/examples/html_scraping.py@@ -1,6 +1,6 @@import osfrom dotenv import load_dotenv-from yosoai.request import send_request+from yosoai import send_requestload_dotenv()diff --git a/examples/value_scraping.py b/examples/value_scraping.pyindex 6c55cb84..041ead84 100644--- a/examples/value_scraping.py+++ b/examples/value_scraping.py@@ -1,7 +1,6 @@import osfrom dotenv import load_dotenv-from yosoai.getter import get_function-from yosoai.request import send_request+from yosoai import get_function, send_requestload_dotenv()diff --git a/pydantic_class.py b/pydantic_class.pyindex 87f2c56d..6a6d72a1 100644--- a/pydantic_class.py+++ b/pydantic_class.py@@ -2,4 +2,4 @@from langchain_core.pydantic_v1 import BaseModel, Fieldclass _Response(BaseModel):- title: str = Field(description='Title of the news')+ title_news: str = Field(description='Give me the name of the news')diff --git a/yosoai/__init__.py b/yosoai/__init__.pyindex fc00b1fe..e7c7a79f 100644--- a/yosoai/__init__.py+++ b/yosoai/__init__.py@@ -1,4 +1,5 @@from .class_creator import create_classfrom .class_generator import Generator-from .pydantic_class import _Response-from .getter import remover\ No newline at end of file+from .getter import remover, get_function+from .token_calculator import truncate_text_tokens+from .request import send_request\ No newline at end of filediff --git a/yosoai/getter.py b/yosoai/getter.pyindex a90632cd..a5a38325 100644--- a/yosoai/getter.py+++ b/yosoai/getter.py@@ -17,7 +17,7 @@ def get_function(link:str, param = HEADERS) -> str:response = requests.get(url=link, headers=param)return str(response.content)-def remover(file:str) -> str:+def remover(file:str, only_body:bool = False) -> str:"""This function elaborates the HTML file and remove all the not necessary tag@@ -30,7 +30,10 @@ def remover(file:str) -> str:res = ""- isBody = False+ if only_body == True:+ isBody = True+ else:+ isBody = Falsefor elem in file.splitlines():if "<title>" in elem:diff --git a/yosoai/request.py b/yosoai/request.pyindex 7333d405..54ce9c45 100644--- a/yosoai/request.py+++ b/yosoai/request.py@@ -32,7 +32,7 @@ def send_request(key: str, text:str, values:list[dict], model:str, temperature:fcreate_class(values)time.sleep(2) # TODO: implement an asynchrous waiting- text = remover(text)+ # text = remover(text)messages = truncate_text_tokens(text, model, encoding_name)