Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
fixed bug for scraping from node + add example
VinciGit00e25f74ddc83a
diff --git a/examples/graph_examples/scrape_plain_text.py b/examples/graph_examples/scrape_plain_text.pynew file mode 100644index 00000000..487c4b74--- /dev/null+++ b/examples/graph_examples/scrape_plain_text.py@@ -0,0 +1,28 @@+"""+Basic example of scraping pipeline using SmartScraper+"""++import os+from dotenv import load_dotenv+from scrapegraphai.graphs import SmartScraperGraph++load_dotenv()+openai_key = os.getenv("OPENAI_APIKEY")++# Define the configuration for the graph+graph_config = {+ "llm": {+ "api_key": openai_key,+ "model": "gpt-3.5-turbo",+ },+}++# Create the SmartScraperGraph instance+smart_scraper_graph = SmartScraperGraph(+ prompt="List me all the news with their description.",+ file_source="/Users/marcovinciguerra/Github/Scrapegraph-ai/examples/graph_examples/plain_html_example.txt",+ config=graph_config+)++result = smart_scraper_graph.run()+print(result)diff --git a/pyproject.toml b/pyproject.tomlindex ec306ecb..d80102f1 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,6 +1,6 @@[tool.poetry]name = "scrapegraphai"-version = "0.0.10"+version = "0.0.11"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/fetch_node.py b/scrapegraphai/nodes/fetch_node.pyindex e761c200..d9247802 100644--- a/scrapegraphai/nodes/fetch_node.py+++ b/scrapegraphai/nodes/fetch_node.py@@ -72,9 +72,9 @@ class FetchNode(BaseNode):if source.endswith(".txt"):with open(source, "r") as file:file_content = file.read()- document = Document(page_content=file_content, metadata={+ document = [Document(page_content=file_content, metadata={"source": source- })+ })]# if it is a URLelse: