mirror of
https://github.com/VinciGit00/Scrapegraph-ai.git
synced 2026-07-06 21:11:37 +08:00
feat: add json multiscraper
This commit is contained in:
parent
4d42d7bfc6
commit
5bda918a39
@ -2,7 +2,8 @@
|
||||
Module for showing how PDFScraper multi works
|
||||
"""
|
||||
import os
|
||||
from scrapegraphai.graphs import PdfScraperMultiGraph
|
||||
import json
|
||||
from scrapegraphai.graphs import JSONScraperMultiGraph
|
||||
|
||||
graph_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))
|
||||
|
||||
@ -16,7 +16,6 @@ graph_config = {
|
||||
"temperature": 0,
|
||||
},
|
||||
"verbose": True,
|
||||
"headless": False,
|
||||
}
|
||||
|
||||
# Covert to list
|
||||
|
||||
@ -17,4 +17,4 @@ from .omni_scraper_graph import OmniScraperGraph
|
||||
from .omni_search_graph import OmniSearchGraph
|
||||
from .smart_scraper_multi_graph import SmartScraperMultiGraph
|
||||
from .pdf_scraper_multi import PdfScraperMultiGraph
|
||||
from .json_scraper_multi import JsonScraperMultiGraph
|
||||
from .json_scraper_multi import JSONScraperMultiGraph
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -19,4 +19,4 @@ from .generate_answer_csv_node import GenerateAnswerCSVNode
|
||||
from .generate_answer_pdf_node import GenerateAnswerPDFNode
|
||||
from .graph_iterator_node import GraphIteratorNode
|
||||
from .merge_answers_node import MergeAnswersNode
|
||||
from .generate_answer_omni_node import GenerateAnswerOmniNode
|
||||
from .generate_answer_omni_node import GenerateAnswerOmniNode
|
||||
|
||||
Loading…
Reference in New Issue
Block a user