Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
refactoring of the examples folder
VinciGit00e08ac716dfdb
diff --git a/examples/direct use/Readme.md b/examples/direct use/Readme.mddeleted file mode 100644index 7b8e226b..00000000--- a/examples/direct use/Readme.md+++ /dev/null@@ -1,2 +0,0 @@-For having interacting examples visit the following collab notebook:-[](https://colab.research.google.com/drive/1sEZBonBMGP44CtO6GQTwAlL0BGJXjtfd?usp=sharing)diff --git a/examples/direct use/custom_graph.py b/examples/direct use/custom_graph.pydeleted file mode 100644index aa9445d7..00000000--- a/examples/direct use/custom_graph.py+++ /dev/null@@ -1,54 +0,0 @@--"""-Example of custom graph using existing nodes-"""-from scrapegraphai.nodes import FetchHTMLNode, ParseHTMLNode, GenerateAnswerNode-from scrapegraphai.graphs import BaseGraph-from scrapegraphai.models import OpenAI-from scrapegraphai.helpers import nodes_metadata--OPENAI_API_KEY = "YOUR_API_KEY"--# check available nodes--nodes_metadata.keys()--# to get more information about a node-print(nodes_metadata['ImageToTextNode'])--# Define the configuration for the language model-llm_config = {- "api_key": OPENAI_API_KEY,- "model_name": "gpt-3.5-turbo",- "temperature": 0,- "streaming": True-}-model = OpenAI(llm_config)--# define the nodes for the graph-fetch_html_node = FetchHTMLNode("fetch_html")-parse_document_node = ParseHTMLNode("parse_document")-generate_answer_node = GenerateAnswerNode(model, "generate_answer")--# create the graph-graph = BaseGraph(- nodes={- fetch_html_node,- parse_document_node,- generate_answer_node- },- edges={- (fetch_html_node, parse_document_node),- (parse_document_node, generate_answer_node)- },- entry_point=fetch_html_node-)--# execute the graph-inputs = {"user_input": "What is the title of the page?",- "url": "https://example.com"}-result = graph.execute(inputs)--# get the answer from the result-answer = result.get("answer", "No answer found.")-print(answer)diff --git a/examples/direct use/graph_builder.py b/examples/direct use/graph_builder.pydeleted file mode 100644index 87cf21ee..00000000--- a/examples/direct use/graph_builder.py+++ /dev/null@@ -1,23 +0,0 @@-"""-Example of graph building-"""-from scrapegraphai.builders import GraphBuilder-OPENAI_API_KEY = "YOUR_API_KEY"---llm_config = {- "api_key": OPENAI_API_KEY,- "model_name": "gpt-3.5-turbo",- "temperature": 0,- "streaming": True-}--# Example usage of GraphBuilder-USER_PROMPT = "Extract the news and generate a text summary with a voiceover."-graph_builder = GraphBuilder(USER_PROMPT, llm_config)-graph_json = graph_builder.build_graph()--# Convert the resulting JSON to Graphviz format-graphviz_graph = graph_builder.convert_json_to_graphviz(graph_json)--print(graph_json)diff --git a/examples/direct use/smart_scraper_graph.py b/examples/direct use/smart_scraper_graph.pydeleted file mode 100644index 6eacc6b1..00000000--- a/examples/direct use/smart_scraper_graph.py+++ /dev/null@@ -1,17 +0,0 @@-"""-Basic example of scraping pipeline using SmartScraper-"""-from scrapegraphai.graphs import SmartScraperGraph-OPENAI_API_KEY = "YOUR_API_KEY"---llm_config = {- "api_key": OPENAI_API_KEY,- "model_name": "gpt-3.5-turbo",-}--smart_scraper_graph = SmartScraperGraph("List me all the titles and project descriptions",- "https://perinim.github.io/projects/", llm_config)--answer = smart_scraper_graph.run()-print(answer["projects"][0])diff --git a/examples/direct use/speech_summary_graph.py b/examples/direct use/speech_summary_graph.pydeleted file mode 100644index 859bcdc8..00000000--- a/examples/direct use/speech_summary_graph.py+++ /dev/null@@ -1,20 +0,0 @@-"""-Basic example of scraping pipeline using SpeechSummaryGraph-"""--from scrapegraphai.graphs import SpeechSummaryGraph-OPENAI_API_KEY = "YOUR_API_KEY"---llm_config = {- "api_key": OPENAI_API_KEY-}--# Save the audio to a file-AUDIO_FILE = "website_summary.mp3"-SPEECH_SUMMARY_GRAPH = SpeechSummaryGraph("Make a summary of the webpage to be converted to audio for blind people.",- "https://perinim.github.io/projects/", llm_config,- AUDIO_FILE)--final_state = SPEECH_SUMMARY_GRAPH.run()-print(final_state.get("answer", "No answer found."))diff --git a/examples/.env.example b/examples/graph_examples/.env.examplesimilarity index 100%rename from examples/.env.examplerename to examples/graph_examples/.env.examplediff --git a/examples/custom_graph_example.py b/examples/graph_examples/custom_graph_example.pysimilarity index 100%rename from examples/custom_graph_example.pyrename to examples/graph_examples/custom_graph_example.pydiff --git a/examples/graph_builder_example.py b/examples/graph_examples/graph_builder_example.pysimilarity index 100%rename from examples/graph_builder_example.pyrename to examples/graph_examples/graph_builder_example.pydiff --git a/examples/graph_evaluation_example.py b/examples/graph_examples/graph_evaluation_example.pysimilarity index 68%rename from examples/graph_evaluation_example.pyrename to examples/graph_examples/graph_evaluation_example.pyindex 5edca641..fcb5da2b 100644--- a/examples/graph_evaluation_example.py+++ b/examples/graph_examples/graph_evaluation_example.py@@ -1,6 +1,9 @@+"""+Module for evaluating the graph+"""import os-from scrapegraphai.evaluetor import TrulensEvaluatorfrom dotenv import load_dotenv+from scrapegraphai.evaluetor import TrulensEvaluatorload_dotenv()@@ -13,8 +16,10 @@ llm_config = {}list_of_inputs = [- ("List me all the titles and project descriptions", "https://perinim.github.io/projects/", llm_config),- ("Who is the author of the project?", "https://perinim.github.io/projects/", llm_config),+ ("List me all the titles and project descriptions",+ "https://perinim.github.io/projects/", llm_config),+ ("Who is the author of the project?",+ "https://perinim.github.io/projects/", llm_config),("What is the project about?", "https://perinim.github.io/projects/", llm_config)]diff --git a/examples/smart_scraper_example.py b/examples/graph_examples/smart_scraper_example.pysimilarity index 100%rename from examples/smart_scraper_example.pyrename to examples/graph_examples/smart_scraper_example.pydiff --git a/examples/speech_summary_graph_example.py b/examples/graph_examples/speech_summary_graph_example.pysimilarity index 100%rename from examples/speech_summary_graph_example.pyrename to examples/graph_examples/speech_summary_graph_example.py