Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
add google search
VinciGit00471df48a220d
diff --git a/scrapegraphai/utils/research_web.py b/scrapegraphai/utils/research_web.pyindex dfb7659a..452d1a9a 100644--- a/scrapegraphai/utils/research_web.py+++ b/scrapegraphai/utils/research_web.py@@ -2,20 +2,37 @@Module for making the request on the web"""import re+from typing import Listfrom langchain_community.tools import DuckDuckGoSearchResults+from googlesearch import search-def search_word_on_web(word, max_results=10):+def search_word_on_web(word: str, web_browser: str = "Google", max_results: int = 10) -> List[str]:"""Function that given a word it finds it on the intenetArgs:- word (str): word to search on internet- max_results (int): maximum number of results+ word (str): word to search on internet+ web_browser (str, optional): type of browser, it could be DuckDuckGo or Google,+ default: Google+ max_results (int, optional): maximum number of results++ Returns:+ List[str]: List of strings of web link"""- search = DuckDuckGoSearchResults(max_results=max_results)- res = search.run(word)+ if web_browser == "Google":+ res = []++ for url in search(web_browser, stop=max_results):+ res.append(url)+ return res+ elif web_browser == "DuckDuckGo":+ research = DuckDuckGoSearchResults(max_results=max_results)+ res = research.run(word)- links = re.findall(r'https?://\S+', res)+ links = re.findall(r'https?://\S+', res)- return links+ return links+ else:+ raise ValueError(+ "The only web browsers avaiable are DuckDuckGo or Google")diff --git a/scrapegraphai/utils/save_audio_from_bytes.py b/scrapegraphai/utils/save_audio_from_bytes.pyindex f250edbf..8f4a3577 100644--- a/scrapegraphai/utils/save_audio_from_bytes.py+++ b/scrapegraphai/utils/save_audio_from_bytes.py@@ -5,7 +5,7 @@ This utility function saves the byte response as an audio file.from pathlib import Path-def save_audio_from_bytes(byte_response, output_path):+def save_audio_from_bytes(byte_response: bytes, output_path):"""Saves the byte response as an audio file.