Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
fixed internet research
VinciGit00a5fc71f34e3a
diff --git a/examples/graph_examples/search_graph_example.py b/examples/graph_examples/search_graph_example.pyindex 458274ef..5d3a2270 100644--- a/examples/graph_examples/search_graph_example.py+++ b/examples/graph_examples/search_graph_example.py@@ -5,6 +5,7 @@ Example of Search Graphimport osfrom dotenv import load_dotenvfrom scrapegraphai.graphs import SearchGraph+from scrapegraphai.utils import convert_to_csv, convert_to_jsonload_dotenv()openai_key = os.getenv("OPENAI_APIKEY")@@ -25,4 +26,8 @@ smart_scraper_graph = SearchGraph()result = smart_scraper_graph.run()-print(result)\ No newline at end of file+print(result)++# Save to json and csv+convert_to_csv(result, "result")+convert_to_json(result, "result")diff --git a/scrapegraphai/nodes/search_internet_node.py b/scrapegraphai/nodes/search_internet_node.pyindex 0b33f79b..88297c1d 100644--- a/scrapegraphai/nodes/search_internet_node.py+++ b/scrapegraphai/nodes/search_internet_node.py@@ -80,7 +80,8 @@ class SearchInternetNode(BaseNode):output_parser = CommaSeparatedListOutputParser()- search_template = """Given the following user prompt, return a query that can be used to search the internet for relevant information. \n+ search_template = """Given the following user prompt, return a query that can be+ used to search the internet for relevant information. \nYou should return only the query string. \nUser Prompt: {user_prompt}"""@@ -95,7 +96,7 @@ class SearchInternetNode(BaseNode):print(f"Search Query: {search_query}")# TODO: handle multiple URLs- answer = search_on_web(query=search_query, search_engine="DuckDuckGo", max_results=1)[0]+ answer = search_on_web(query=search_query, max_results=1)[0]# Update the state with the generated answerstate.update({self.output[0]: answer})