Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
add new version + refactoring of the code
VinciGit00958b2a4a7950
diff --git a/README.md b/README.mdindex ad04e4cc..a3cbc6a6 100644--- a/README.md+++ b/README.md@@ -43,12 +43,18 @@ Check out also the docusaurus [documentation](https://scrapegraph-doc.onrender.c## 💻 Usage-### Case 1: Extracting information using a prompt+### Case 1: Extracting informations using a local LLMYou can use the `SmartScraper` class to extract information from a website using a prompt.The `SmartScraper` class is a direct graph implementation that uses the most common nodes present in a web scraping pipeline. For more information, please see the [documentation](https://scrapegraph-ai.readthedocs.io/en/latest/).+```python++```+++### Case 2: Extracting informations using Openai model```pythonfrom scrapegraphai.graphs import SmartScraperGraphOPENAI_API_KEY = "YOUR_API_KEY"@@ -72,7 +78,31 @@ result = smart_scraper_graph.run()print(result)```-The output will be a dictionary with the extracted information, for example:+### Case 3: Extracting informations using Gemini+```python+from scrapegraphai.graphs import SmartScraperGraph+GOOGLE_APIKEY = "YOUR_API_KEY"++# Define the configuration for the graph+graph_config = {+ "llm": {+ "api_key": GOOGLE_APIKEY,+ "model": "gemini-pro",+ },+}++# Create the SmartScraperGraph instance+smart_scraper_graph = SmartScraperGraph(+ prompt="List me all the quotes, authors and tags ",+ file_source="http://quotes.toscrape.com", # also accepts a string with the already downloaded HTML code as string format+ config=graph_config+)++result = smart_scraper_graph.run()+print(result)+```++The output for alle 3 the cases will be a dictionary with the extracted information, for example:```bash{diff --git a/examples/custom_graph_gemini.py b/examples/gemini/custom_graph_gemini.pysimilarity index 97%rename from examples/custom_graph_gemini.pyrename to examples/gemini/custom_graph_gemini.pyindex 7d663773..4380bd53 100644--- a/examples/custom_graph_gemini.py+++ b/examples/gemini/custom_graph_gemini.py@@ -7,7 +7,6 @@ from dotenv import load_dotenvfrom scrapegraphai.models import Geminifrom scrapegraphai.graphs import BaseGraphfrom scrapegraphai.nodes import FetchNode, ParseNode, RAGNode, GenerateAnswerNode-from scrapegraphai.helpers import models_tokensload_dotenv()# ************************************************diff --git a/examples/custom_graph_openai.py b/examples/openai/custom_graph_openai.pysimilarity index 97%rename from examples/custom_graph_openai.pyrename to examples/openai/custom_graph_openai.pyindex d92cf3dd..98ebcea3 100644--- a/examples/custom_graph_openai.py+++ b/examples/openai/custom_graph_openai.py@@ -7,7 +7,6 @@ from dotenv import load_dotenvfrom scrapegraphai.models import OpenAIfrom scrapegraphai.graphs import BaseGraphfrom scrapegraphai.nodes import FetchNode, ParseNode, RAGNode, GenerateAnswerNode-from scrapegraphai.helpers import models_tokensload_dotenv()# ************************************************@@ -82,4 +81,4 @@ result = graph.execute({# get the answer from the resultresult = result.get("answer", "No answer found.")-print(result)\ No newline at end of file+print(result)diff --git a/examples/inputs/books.xml b/examples/openai/inputs/books.xmlsimilarity index 100%rename from examples/inputs/books.xmlrename to examples/openai/inputs/books.xmldiff --git a/examples/inputs/plain_html_example.txt b/examples/openai/inputs/plain_html_example.txtsimilarity index 100%rename from examples/inputs/plain_html_example.txtrename to examples/openai/inputs/plain_html_example.txtdiff --git a/examples/results/result.csv b/examples/openai/results/result.csvsimilarity index 100%rename from examples/results/result.csvrename to examples/openai/results/result.csvdiff --git a/examples/results/result.json b/examples/openai/results/result.jsonsimilarity index 100%rename from examples/results/result.jsonrename to examples/openai/results/result.jsondiff --git a/examples/scrape_plain_text.py b/examples/openai/scrape_plain_text.pysimilarity index 100%rename from examples/scrape_plain_text.pyrename to examples/openai/scrape_plain_text.pydiff --git a/examples/scrape_xml_document.py b/examples/openai/scrape_xml_document.pysimilarity index 100%rename from examples/scrape_xml_document.pyrename to examples/openai/scrape_xml_document.pydiff --git a/examples/search_graph_example.py b/examples/openai/search_graph_example.pysimilarity index 100%rename from examples/search_graph_example.pyrename to examples/openai/search_graph_example.pydiff --git a/examples/smart_scraper_example.py b/examples/openai/smart_scraper_example.pysimilarity index 100%rename from examples/smart_scraper_example.pyrename to examples/openai/smart_scraper_example.pydiff --git a/examples/speech_graph_example.py b/examples/openai/speech_graph_example.pysimilarity index 100%rename from examples/speech_graph_example.pyrename to examples/openai/speech_graph_example.pydiff --git a/pyproject.toml b/pyproject.tomlindex 649ee00a..22ffb592 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,6 +1,6 @@[tool.poetry]name = "scrapegraphai"-version = "0.0.16"+version = "0.1.0"description = "A web scraping library based on LangChain which uses LLM and direct graph logic to create scraping pipelines."authors = ["Marco Vinciguerra <[email protected]>",