Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
add progress bar and refactoring of remover function
VinciGit00eb04e4399c4c
diff --git a/yosoai/getter.py b/yosoai/getter.pyindex a5a38325..ba6f5f34 100644--- a/yosoai/getter.py+++ b/yosoai/getter.py@@ -51,4 +51,4 @@ def remover(file:str, only_body:bool = False) -> str:if isBody == True:res = res + elem- return res.replace("\n", "")\ No newline at end of file+ return res.replace("\\n", "")\ No newline at end of filediff --git a/yosoai/request.py b/yosoai/request.pyindex 54ce9c45..367d42e0 100644--- a/yosoai/request.py+++ b/yosoai/request.py@@ -1,4 +1,5 @@import time+from tqdm import tqdmfrom typing import Listfrom .getter import removerfrom .class_generator import Generator@@ -32,19 +33,20 @@ 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)- count = 0+ processed_messages = 0- for message in messages:- generator_instance = Generator(key, temperature, model)+ with tqdm(total=len(messages)) as pbar:+ for message in messages:+ generator_instance = Generator(key, temperature, model)- res.append(generator_instance.invocation(message))+ res.append(generator_instance.invocation(message))+ processed_messages += 1+ pbar.update(1)- print(res)- print(f"Percentage: {round(count/len(messages),2)*100}%")- count +=1+ print(res)return res\ No newline at end of file