Skip to content

Python scraper based on AI

fix: update broken test imports to match current API

khadyottakale536e5adcde17
diff --git a/tests/graphs/scrape_graph_test.py b/tests/graphs/scrape_graph_test.py
index 272fc238..89c5464b 100644
--- a/tests/graphs/scrape_graph_test.py
+++ b/tests/graphs/scrape_graph_test.py
@@ -1,5 +1,5 @@
"""
-Module for testing the scrape graph class
+Module for testing the smart scraper graph class
"""
import os
@@ -7,7 +7,7 @@ import os
import pytest
from dotenv import load_dotenv
-from scrapegraphai.graphs import ScrapeGraph
+from scrapegraphai.graphs import SmartScraperGraph
load_dotenv()
@@ -19,7 +19,7 @@ def graph_config():
return {
"llm": {
"api_key": openai_key,
- "model": "openai/gpt-3.5-turbo",
+ "model": "openai/gpt-4o",
},
"verbose": True,
"headless": False,
@@ -28,26 +28,27 @@ def graph_config():
def test_scraping_pipeline(graph_config):
"""Start of the scraping pipeline"""
- scrape_graph = ScrapeGraph(
+ smart_scraper_graph = SmartScraperGraph(
+ prompt="List me all the projects with their descriptions",
source="https://perinim.github.io/projects/",
config=graph_config,
)
- result = scrape_graph.run()
+ result = smart_scraper_graph.run()
assert result is not None
- assert isinstance(result, list)
def test_get_execution_info(graph_config):
"""Get the execution info"""
- scrape_graph = ScrapeGraph(
+ smart_scraper_graph = SmartScraperGraph(
+ prompt="List me all the projects with their descriptions",
source="https://perinim.github.io/projects/",
config=graph_config,
)
- scrape_graph.run()
+ smart_scraper_graph.run()
- graph_exec_info = scrape_graph.get_execution_info()
+ graph_exec_info = smart_scraper_graph.get_execution_info()
assert graph_exec_info is not None
diff --git a/tests/graphs/xml_scraper_openai_test.py b/tests/graphs/xml_scraper_openai_test.py
index cb2b4aa3..65bc240f 100644
--- a/tests/graphs/xml_scraper_openai_test.py
+++ b/tests/graphs/xml_scraper_openai_test.py
@@ -8,7 +8,7 @@ import pytest
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperGraph
-from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+from scrapegraphai.utils import export_to_csv, export_to_json, prettify_exec_info
load_dotenv()
@@ -96,8 +96,8 @@ def test_xml_scraper_save_results(graph_config: dict, xml_content: str):
result = xml_scraper_graph.run()
# Save to csv and json
- convert_to_csv(result, "result")
- convert_to_json(result, "result")
+ export_to_csv(result, "result")
+ export_to_json(result, "result")
assert os.path.exists("result.csv")
assert os.path.exists("result.json")