Skip to content

Commit 2a15581

Browse files
committed
fix: local html handling
1 parent 013a196 commit 2a15581

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

examples/openai/xml_scraper_openai.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
from dotenv import load_dotenv
66
from scrapegraphai.graphs import XMLScraperGraph
7-
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
7+
from scrapegraphai.utils import prettify_exec_info
88

99
load_dotenv()
1010

@@ -23,7 +23,7 @@
2323
# Define the configuration for the graph
2424
# ************************************************
2525

26-
openai_key = os.getenv("OPENAI_APIKEY")
26+
openai_key = os.getenv("OPENAI_API_KEY")
2727

2828
graph_config = {
2929
"llm": {
@@ -53,6 +53,3 @@
5353
graph_exec_info = xml_scraper_graph.get_execution_info()
5454
print(prettify_exec_info(graph_exec_info))
5555

56-
# Save to json or csv
57-
convert_to_csv(result, "result")
58-
convert_to_json(result, "result")

scrapegraphai/graphs/smart_scraper_graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def _create_graph(self) -> BaseGraph:
9191
return response
9292

9393
fetch_node = FetchNode(
94-
input="url| local_dir",
94+
input="url | local_dir",
9595
output=["doc"],
9696
node_config={
9797
"llm_model": self.llm_model,

scrapegraphai/nodes/fetch_node.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,13 @@ def execute(self, state):
107107

108108
if input_type in handlers:
109109
return handlers[input_type](state, input_type, source)
110-
elif self.input == "pdf_dir":
111-
return state
112-
113-
try:
110+
elif input_type == "local_dir":
111+
return self.handle_local_source(state, source)
112+
elif input_type == "url":
114113
return self.handle_web_source(state, source)
115-
except ValueError as e:
116-
raise
114+
else:
115+
raise ValueError(f"Invalid input type: {input_type}")
117116

118-
return self.handle_local_source(state, source)
119117

120118
def handle_directory(self, state, input_type, source):
121119
"""

0 commit comments

Comments
 (0)