Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
feat: add json multiscraper
Marco Vinciguerra5bda918a39e4
diff --git a/examples/local_models/json_scraper_multi_ollama.py b/examples/local_models/json_scraper_multi_ollama.pyindex d3540301..2754425c 100644--- a/examples/local_models/json_scraper_multi_ollama.py+++ b/examples/local_models/json_scraper_multi_ollama.py@@ -2,7 +2,8 @@Module for showing how PDFScraper multi works"""import os-from scrapegraphai.graphs import PdfScraperMultiGraph+import json+from scrapegraphai.graphs import JSONScraperMultiGraphgraph_config = {"llm": {@@ -25,23 +26,14 @@ file_path = os.path.join(curr_dir, FILE_NAME)with open(file_path, 'r', encoding="utf-8") as file:text = file.read()--json_scraper_graph = JSONScraperGraph(- prompt="List me all the authors, title and genres of the books",- source=text, # Pass the content of the file, not the file object+sources = [text, text]++multiple_search_graph = JSONScraperMultiGraph(+ prompt= "List me all the authors, title and genres of the books",+ source= sources,+ schema=None,config=graph_config)---results = []-for source in sources:- pdf_scraper_graph = PdfScraperMultiGraph(- prompt=prompt,- source=source,- config=graph_config- )- result = pdf_scraper_graph.run()- results.append(result)--print(results)+result = multiple_search_graph.run()+print(json.dumps(result, indent=4))diff --git a/examples/local_models/pdf_scraper_multi_ollama.py b/examples/local_models/pdf_scraper_multi_ollama.pyindex 77565918..c0b65a63 100644--- a/examples/local_models/pdf_scraper_multi_ollama.py+++ b/examples/local_models/pdf_scraper_multi_ollama.py@@ -16,7 +16,6 @@ graph_config = {"temperature": 0,},"verbose": True,- "headless": False,}# Covert to listdiff --git a/scrapegraphai/graphs/__init__.py b/scrapegraphai/graphs/__init__.pyindex b70686a7..37814cd1 100644--- a/scrapegraphai/graphs/__init__.py+++ b/scrapegraphai/graphs/__init__.py@@ -17,4 +17,4 @@ from .omni_scraper_graph import OmniScraperGraphfrom .omni_search_graph import OmniSearchGraphfrom .smart_scraper_multi_graph import SmartScraperMultiGraphfrom .pdf_scraper_multi import PdfScraperMultiGraph-from .json_scraper_multi import JsonScraperMultiGraph+from .json_scraper_multi import JSONScraperMultiGraphdiff --git a/scrapegraphai/graphs/json_scraper_multi.py b/scrapegraphai/graphs/json_scraper_multi.pyindex c7632d79..2010c856 100644--- a/scrapegraphai/graphs/json_scraper_multi.py+++ b/scrapegraphai/graphs/json_scraper_multi.py@@ -1,5 +1,5 @@"""-JsonScraperMultiGraph Module+JSONScraperMultiGraph Module"""from copy import copy, deepcopy@@ -15,9 +15,9 @@ from ..nodes import ()-class JsonScraperMultiGraph(AbstractGraph):+class JSONScraperMultiGraph(AbstractGraph):"""- JsonScraperMultiGraph is a scraping pipeline that scrapes a list of URLs and generates answers to a given prompt.+ JSONScraperMultiGraph is a scraping pipeline that scrapes a list of URLs and generates answers to a given prompt.It only requires a user prompt and a list of URLs.Attributes:diff --git a/scrapegraphai/nodes/__init__.py b/scrapegraphai/nodes/__init__.pyindex 4577ee86..5c54937c 100644--- a/scrapegraphai/nodes/__init__.py+++ b/scrapegraphai/nodes/__init__.py@@ -19,4 +19,4 @@ from .generate_answer_csv_node import GenerateAnswerCSVNodefrom .generate_answer_pdf_node import GenerateAnswerPDFNodefrom .graph_iterator_node import GraphIteratorNodefrom .merge_answers_node import MergeAnswersNode-from .generate_answer_omni_node import GenerateAnswerOmniNode\ No newline at end of file+from .generate_answer_omni_node import GenerateAnswerOmniNode