Skip to content

Commit e0978c5

Browse files
committed
Merge branch 'main' into ollama_integration
2 parents 3640434 + 8ff27be commit e0978c5

23 files changed

Lines changed: 350 additions & 224 deletions

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ venv/
2828
*.sqlite
2929
*.google-cookie
3030
examples/graph_examples/ScrapeGraphAI_generated_graph
31-
examples/*.csv
32-
examples/*.json
31+
examples/**/*.csv
32+
examples/**/*.json
3333
main.py

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM python:3.11-slim
2+
3+
RUN apt-get update && apt-get upgrade -y && \
4+
useradd -m -s /bin/bash app
5+
6+
USER app
7+
8+
RUN pip install scrapegraphai

examples/gemini/custom_graph_gemini.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
# Execute the graph
7575
# ************************************************
7676

77-
result = graph.execute({
77+
result, execution_info = graph.execute({
7878
"user_prompt": "List me the projects with their description",
7979
"url": "https://perinim.github.io/projects/"
8080
})

examples/local_models/Docker/scrape_plain_text_docker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
# ************************************************
4141

4242
smart_scraper_graph = SmartScraperGraph(
43-
prompt="List me all the news with their description.",
43+
prompt="List me all the projects with their description.",
4444
source=text,
4545
config=graph_config
4646
)

examples/local_models/Docker/smart_scraper_docker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
smart_scraper_graph = SmartScraperGraph(
2424
prompt="List me all the news with their description.",
2525
# also accepts a string with the already downloaded HTML code
26-
source="https://perinim.github.io/projects",
26+
source="https://www.wired.com/category/science/",
2727
config=graph_config
2828
)
2929

examples/mixed_models/search_graph_mixed.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
from dotenv import load_dotenv
77
from scrapegraphai.graphs import SearchGraph
8-
from scrapegraphai.utils import convert_to_csv, convert_to_json
8+
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
99
load_dotenv()
1010

1111
# ************************************************
@@ -38,6 +38,13 @@
3838
result = search_graph.run()
3939
print(result)
4040

41+
# ************************************************
42+
# Get graph execution info
43+
# ************************************************
44+
45+
graph_exec_info = search_graph.get_execution_info()
46+
print(prettify_exec_info(graph_exec_info))
47+
4148
# Save to json and csv
4249
convert_to_csv(result, "result")
4350
convert_to_json(result, "result")

examples/openai/custom_graph_openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
# Execute the graph
7575
# ************************************************
7676

77-
result = graph.execute({
77+
result, execution_info = graph.execute({
7878
"user_prompt": "List me the projects with their description",
7979
"url": "https://perinim.github.io/projects/"
8080
})

examples/openai/scrape_plain_text_openai.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
from dotenv import load_dotenv
77
from scrapegraphai.graphs import SmartScraperGraph
8-
from scrapegraphai.utils import convert_to_csv, convert_to_json
8+
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
99
load_dotenv()
1010

1111
# ************************************************
@@ -46,6 +46,13 @@
4646
result = smart_scraper_graph.run()
4747
print(result)
4848

49+
# ************************************************
50+
# Get graph execution info
51+
# ************************************************
52+
53+
graph_exec_info = smart_scraper_graph.get_execution_info()
54+
print(prettify_exec_info(graph_exec_info))
55+
4956
# Save to json or csv
5057
convert_to_csv(result, "result")
5158
convert_to_json(result, "result")

examples/openai/scrape_xml_openai.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
from dotenv import load_dotenv
77
from scrapegraphai.graphs import SmartScraperGraph
8-
from scrapegraphai.utils import convert_to_csv, convert_to_json
8+
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
99
load_dotenv()
1010

1111
# ************************************************
@@ -45,6 +45,13 @@
4545
result = smart_scraper_graph.run()
4646
print(result)
4747

48+
# ************************************************
49+
# Get graph execution info
50+
# ************************************************
51+
52+
graph_exec_info = smart_scraper_graph.get_execution_info()
53+
print(prettify_exec_info(graph_exec_info))
54+
4855
# Save to json or csv
4956
convert_to_csv(result, "result")
5057
convert_to_json(result, "result")

examples/openai/search_graph_openai.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
from dotenv import load_dotenv
77
from scrapegraphai.graphs import SearchGraph
8-
from scrapegraphai.utils import convert_to_csv, convert_to_json
8+
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
99
load_dotenv()
1010

1111
# ************************************************
@@ -26,13 +26,20 @@
2626
# ************************************************
2727

2828
search_graph = SearchGraph(
29-
prompt="List me all the regions of Italy.",
29+
prompt="List me top 5 eyeliner products for a gift.",
3030
config=graph_config
3131
)
3232

3333
result = search_graph.run()
3434
print(result)
3535

36+
# ************************************************
37+
# Get graph execution info
38+
# ************************************************
39+
40+
graph_exec_info = search_graph.get_execution_info()
41+
print(prettify_exec_info(graph_exec_info))
42+
3643
# Save to json and csv
3744
convert_to_csv(result, "result")
3845
convert_to_json(result, "result")

0 commit comments

Comments
 (0)