Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
recatoring of nodes excluive for openai
VinciGit00a2349e56af42
diff --git a/pyproject.toml b/pyproject.tomlindex 21bca442..caccc0a5 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,6 +1,6 @@[tool.poetry]name = "scrapegraphai"-version = "0.2.1"+version = "0.2.2"description = "A web scraping library based on LangChain which uses LLM and direct graph logic to create scraping pipelines."authors = ["Marco Vinciguerra <[email protected]>",diff --git a/scrapegraphai/nodes/__init__.py b/scrapegraphai/nodes/__init__.pyindex b5b03d73..7cd1a1c4 100644--- a/scrapegraphai/nodes/__init__.py+++ b/scrapegraphai/nodes/__init__.py@@ -8,7 +8,7 @@ from .get_probable_tags_node import GetProbableTagsNodefrom .generate_answer_node import GenerateAnswerNodefrom .parse_node import ParseNodefrom .rag_node import RAGNode-from .text_to_speech_node import TextToSpeechNode-from .image_to_text_node import ImageToTextNode+from .text_to_speech_node_openai import TextToSpeechNode+from .image_to_text_node_openai import ImageToTextNodefrom .search_internet_node import SearchInternetNodefrom .generate_scraper_node import GenerateScraperNodediff --git a/scrapegraphai/nodes/image_to_text_node.py b/scrapegraphai/nodes/image_to_text_node_openai.pysimilarity index 100%rename from scrapegraphai/nodes/image_to_text_node.pyrename to scrapegraphai/nodes/image_to_text_node_openai.pydiff --git a/scrapegraphai/nodes/text_to_speech_node.py b/scrapegraphai/nodes/text_to_speech_node_openai.pysimilarity index 100%rename from scrapegraphai/nodes/text_to_speech_node.pyrename to scrapegraphai/nodes/text_to_speech_node_openai.pydiff --git a/tests/scrape_plain_text_ollama_test.py b/tests/scrape_plain_text_ollama_test.pyindex 0b37b205..919d48c0 100644--- a/tests/scrape_plain_text_ollama_test.py+++ b/tests/scrape_plain_text_ollama_test.py@@ -8,7 +8,9 @@ from scrapegraphai.graphs import SmartScraperGraph@pytest.fixturedef sample_text():- # Read the sample text file+ """+ Example of text+ """file_name = "inputs/plain_html_example.txt"curr_dir = os.path.dirname(os.path.realpath(__file__))file_path = os.path.join(curr_dir, file_name)@@ -21,6 +23,9 @@ def sample_text():@pytest.fixturedef graph_config():+ """+ Configuration of the graph+ """return {"llm": {"model": "ollama/mistral",@@ -36,16 +41,16 @@ def graph_config():}-def test_scraping_pipeline(sample_text, graph_config):- # Create the SmartScraperGraph instance+def test_scraping_pipeline(sample_text: str, graph_config: dict):+ """+ Start of the scraping pipeline+ """smart_scraper_graph = SmartScraperGraph(prompt="List me all the news with their description.",source=sample_text,config=graph_config)- # Run the graphresult = smart_scraper_graph.run()- # Check that the result is not emptyassert result is not Nonediff --git a/tests/scrape_xml_ollama_test.py b/tests/scrape_xml_ollama_test.pyindex 343e4ecc..afa7527f 100644--- a/tests/scrape_xml_ollama_test.py+++ b/tests/scrape_xml_ollama_test.py@@ -8,7 +8,9 @@ from scrapegraphai.graphs import SmartScraperGraph@pytest.fixturedef sample_xml():- # Leggi il file XML di esempio+ """+ Example of text+ """file_name = "inputs/books.xml"curr_dir = os.path.dirname(os.path.realpath(__file__))file_path = os.path.join(curr_dir, file_name)@@ -21,6 +23,9 @@ def sample_xml():@pytest.fixturedef graph_config():+ """+ Configuration of the graph+ """return {"llm": {"model": "ollama/mistral",@@ -36,16 +41,16 @@ def graph_config():}-def test_scraping_pipeline(sample_xml, graph_config):- # Crea un'istanza di SmartScraperGraph+def test_scraping_pipeline(sample_xml: str, graph_config: dict):+ """+ Start of the scraping pipeline+ """smart_scraper_graph = SmartScraperGraph(prompt="List me all the authors, title and genres of the books",source=sample_xml,config=graph_config)- # Esegui il graficoresult = smart_scraper_graph.run()- # Verifica che il risultato non sia vuotoassert result is not Nonediff --git a/tests/script_generator_test.py b/tests/script_generator_test.pyindex b0f1c343..6114bac4 100644--- a/tests/script_generator_test.py+++ b/tests/script_generator_test.py@@ -1,9 +1,5 @@"""-<<<<<<< Updated upstreamModule for making the tests for ScriptGeneratorGraph-=======-Test for script generator->>>>>>> Stashed changes"""import pytestfrom scrapegraphai.graphs import ScriptCreatorGraph@@ -12,6 +8,9 @@ from scrapegraphai.utils import prettify_exec_info@pytest.fixturedef graph_config():+ """+ Configuration of the graph+ """return {"llm": {"model": "ollama/mistral",@@ -29,28 +28,24 @@ def graph_config():}-def test_script_creator_graph(graph_config):- # Create the ScriptCreatorGraph instance+def test_script_creator_graph(graph_config: dict):+ """+ Start of the scraping pipeline+ """smart_scraper_graph = ScriptCreatorGraph(prompt="List me all the news with their description.",source="https://perinim.github.io/projects",config=graph_config)- # Run the graphresult = smart_scraper_graph.run()- # Check that the result is not emptyassert result is not None- # Get graph execution infograph_exec_info = smart_scraper_graph.get_execution_info()- # Check that execution info is not emptyassert graph_exec_info is not None- # Check that execution info is a dictionaryassert isinstance(graph_exec_info, dict)- # Print execution infoprint(prettify_exec_info(graph_exec_info))diff --git a/tests/smart_scraper_ollama_test.py b/tests/smart_scraper_ollama_test.pyindex 70eb9af6..b35907c0 100644--- a/tests/smart_scraper_ollama_test.py+++ b/tests/smart_scraper_ollama_test.py@@ -7,6 +7,9 @@ from scrapegraphai.graphs import SmartScraperGraph@pytest.fixturedef graph_config():+ """+ Configuration of the graph+ """return {"llm": {"model": "ollama/mistral",@@ -22,34 +25,33 @@ def graph_config():}-def test_scraping_pipeline(graph_config):- # Crea un'istanza di SmartScraperGraph+def test_scraping_pipeline(graph_config: dict):+ """+ Start of the scraping pipeline+ """smart_scraper_graph = SmartScraperGraph(prompt="List me all the news with their description.",source="https://perinim.github.io/projects",config=graph_config)- # Esegui il graficoresult = smart_scraper_graph.run()- # Verifica che il risultato non sia vuotoassert result is not None-def test_get_execution_info(graph_config):- # Crea un'istanza di SmartScraperGraph+def test_get_execution_info(graph_config: dict):+ """+ Get the execution info+ """smart_scraper_graph = SmartScraperGraph(prompt="List me all the news with their description.",source="https://perinim.github.io/projects",config=graph_config)- # Esegui il graficosmart_scraper_graph.run()- # Ottieni le informazioni sull'esecuzione del graficograph_exec_info = smart_scraper_graph.get_execution_info()- # Verifica che le informazioni sull'esecuzione non siano vuoteassert graph_exec_info is not None