feat(refactor): changed variable names

This commit is contained in:
EURAC\marperini 2024-04-30 14:28:30 +02:00
parent da2c82a2a2
commit 8fba7e5490
13 changed files with 54 additions and 52 deletions

View File

@ -1,10 +1,10 @@
""" """
Basic example of scraping pipeline using SmartScraper from JSON documents Basic example of scraping pipeline using JSONScraperGraph from JSON documents
""" """
import os import os
from dotenv import load_dotenv from dotenv import load_dotenv
from scrapegraphai.graphs import JsonScraperGraph from scrapegraphai.graphs import JSONScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
load_dotenv() load_dotenv()
@ -33,23 +33,23 @@ graph_config = {
} }
# ************************************************ # ************************************************
# Create the JsonScraperGraph instance and run it # Create the JSONScraperGraph instance and run it
# ************************************************ # ************************************************
smart_scraper_graph = JsonScraperGraph( json_scraper_graph = JSONScraperGraph(
prompt="List me all the authors, title and genres of the books", prompt="List me all the authors, title and genres of the books",
source=text, # Pass the content of the file, not the file object source=text, # Pass the content of the file, not the file object
config=graph_config config=graph_config
) )
result = smart_scraper_graph.run() result = json_scraper_graph.run()
print(result) print(result)
# ************************************************ # ************************************************
# Get graph execution info # Get graph execution info
# ************************************************ # ************************************************
graph_exec_info = smart_scraper_graph.get_execution_info() graph_exec_info = json_scraper_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info)) print(prettify_exec_info(graph_exec_info))
# Save to json or csv # Save to json or csv

View File

@ -1,10 +1,10 @@
""" """
Basic example of scraping pipeline using XmlScraperGraph from XML documents Basic example of scraping pipeline using XMLScraperGraph from XML documents
""" """
import os import os
from dotenv import load_dotenv from dotenv import load_dotenv
from scrapegraphai.graphs import XmlScraperGraph from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
load_dotenv() load_dotenv()
@ -33,23 +33,23 @@ graph_config = {
} }
# ************************************************ # ************************************************
# Create the XmlScraperGraph instance and run it # Create the XMLScraperGraph instance and run it
# ************************************************ # ************************************************
smart_scraper_graph = XmlScraperGraph( xml_scraper_graph = XMLScraperGraph(
prompt="List me all the authors, title and genres of the books", prompt="List me all the authors, title and genres of the books",
source=text, # Pass the content of the file, not the file object source=text, # Pass the content of the file, not the file object
config=graph_config config=graph_config
) )
result = smart_scraper_graph.run() result = xml_scraper_graph.run()
print(result) print(result)
# ************************************************ # ************************************************
# Get graph execution info # Get graph execution info
# ************************************************ # ************************************************
graph_exec_info = smart_scraper_graph.get_execution_info() graph_exec_info = xml_scraper_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info)) print(prettify_exec_info(graph_exec_info))
# Save to json or csv # Save to json or csv

View File

@ -1,10 +1,10 @@
""" """
Basic example of scraping pipeline using JsonScraperGraph from JSON documents Basic example of scraping pipeline using JSONScraperGraph from JSON documents
""" """
import os import os
from dotenv import load_dotenv from dotenv import load_dotenv
from scrapegraphai.graphs import JsonScraperGraph from scrapegraphai.graphs import JSONScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
load_dotenv() load_dotenv()
@ -37,23 +37,23 @@ graph_config = {
} }
# ************************************************ # ************************************************
# Create the JsonScraperGraph instance and run it # Create the JSONScraperGraph instance and run it
# ************************************************ # ************************************************
smart_scraper_graph = JsonScraperGraph( json_scraper_graph = JSONScraperGraph(
prompt="List me all the authors, title and genres of the books", prompt="List me all the authors, title and genres of the books",
source=text, # Pass the content of the file, not the file object source=text, # Pass the content of the file, not the file object
config=graph_config config=graph_config
) )
result = smart_scraper_graph.run() result = json_scraper_graph.run()
print(result) print(result)
# ************************************************ # ************************************************
# Get graph execution info # Get graph execution info
# ************************************************ # ************************************************
graph_exec_info = smart_scraper_graph.get_execution_info() graph_exec_info = json_scraper_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info)) print(prettify_exec_info(graph_exec_info))
# Save to json or csv # Save to json or csv

View File

@ -1,10 +1,10 @@
""" """
Basic example of scraping pipeline using XmlScraperGraph from XML documents Basic example of scraping pipeline using XMLScraperGraph from XML documents
""" """
import os import os
from dotenv import load_dotenv from dotenv import load_dotenv
from scrapegraphai.graphs import XmlScraperGraph from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
load_dotenv() load_dotenv()
@ -37,23 +37,23 @@ graph_config = {
} }
# ************************************************ # ************************************************
# Create the XmlScraperGraph instance and run it # Create the XMLScraperGraph instance and run it
# ************************************************ # ************************************************
smart_scraper_graph = XmlScraperGraph( xml_scraper_graph = XMLScraperGraph(
prompt="List me all the authors, title and genres of the books", prompt="List me all the authors, title and genres of the books",
source=text, # Pass the content of the file, not the file object source=text, # Pass the content of the file, not the file object
config=graph_config config=graph_config
) )
result = smart_scraper_graph.run() result = xml_scraper_graph.run()
print(result) print(result)
# ************************************************ # ************************************************
# Get graph execution info # Get graph execution info
# ************************************************ # ************************************************
graph_exec_info = smart_scraper_graph.get_execution_info() graph_exec_info = xml_scraper_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info)) print(prettify_exec_info(graph_exec_info))
# Save to json or csv # Save to json or csv

View File

@ -1,10 +1,10 @@
""" """
Basic example of scraping pipeline using JsonScraperGraph from JSON documents Basic example of scraping pipeline using JSONScraperGraph from JSON documents
""" """
import os import os
from dotenv import load_dotenv from dotenv import load_dotenv
from scrapegraphai.graphs import JsonScraperGraph from scrapegraphai.graphs import JSONScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
load_dotenv() load_dotenv()
@ -39,23 +39,23 @@ graph_config = {
} }
# ************************************************ # ************************************************
# Create the XmlScraperGraph instance and run it # Create the JSONScraperGraph instance and run it
# ************************************************ # ************************************************
smart_scraper_graph = JsonScraperGraph( json_scraper_graph = JSONScraperGraph(
prompt="List me all the authors, title and genres of the books", prompt="List me all the authors, title and genres of the books",
source=text, # Pass the content of the file, not the file object source=text, # Pass the content of the file, not the file object
config=graph_config config=graph_config
) )
result = smart_scraper_graph.run() result = json_scraper_graph.run()
print(result) print(result)
# ************************************************ # ************************************************
# Get graph execution info # Get graph execution info
# ************************************************ # ************************************************
graph_exec_info = smart_scraper_graph.get_execution_info() graph_exec_info = json_scraper_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info)) print(prettify_exec_info(graph_exec_info))
# Save to json or csv # Save to json or csv

View File

@ -1,10 +1,10 @@
""" """
Basic example of scraping pipeline using XmlScraperGraph from XML documents Basic example of scraping pipeline using XMLScraperGraph from XML documents
""" """
import os import os
from dotenv import load_dotenv from dotenv import load_dotenv
from scrapegraphai.graphs import XmlScraperGraph from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
load_dotenv() load_dotenv()
@ -39,23 +39,23 @@ graph_config = {
} }
# ************************************************ # ************************************************
# Create the XmlScraperGraph instance and run it # Create the XMLScraperGraph instance and run it
# ************************************************ # ************************************************
smart_scraper_graph = XmlScraperGraph( xml_scraper_graph = XMLScraperGraph(
prompt="List me all the authors, title and genres of the books", prompt="List me all the authors, title and genres of the books",
source=text, # Pass the content of the file, not the file object source=text, # Pass the content of the file, not the file object
config=graph_config config=graph_config
) )
result = smart_scraper_graph.run() result = xml_scraper_graph.run()
print(result) print(result)
# ************************************************ # ************************************************
# Get graph execution info # Get graph execution info
# ************************************************ # ************************************************
graph_exec_info = smart_scraper_graph.get_execution_info() graph_exec_info = xml_scraper_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info)) print(prettify_exec_info(graph_exec_info))
# Save to json or csv # Save to json or csv

View File

@ -0,0 +1 @@
{"projects": [{"title": "Rotary Pendulum RL", "description": "Open Source project aimed at controlling a real life rotary pendulum using RL algorithms"}, {"title": "DQN Implementation from scratch", "description": "Developed a Deep Q-Network algorithm to train a simple and double pendulum"}, {"title": "Multi Agents HAED", "description": "University project which focuses on simulating a multi-agent system to perform environment mapping. Agents, equipped with sensors, explore and record their surroundings, considering uncertainties in their readings."}, {"title": "Wireless ESC for Modular Drones", "description": "Modular drone architecture proposal and proof of concept. The project received maximum grade."}]}

View File

@ -1,10 +1,10 @@
""" """
Basic example of scraping pipeline using JsonScraperGraph from JSON documents Basic example of scraping pipeline using JSONScraperGraph from JSON documents
""" """
import os import os
from dotenv import load_dotenv from dotenv import load_dotenv
from scrapegraphai.graphs import JsonScraperGraph from scrapegraphai.graphs import JSONScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
load_dotenv() load_dotenv()
@ -33,23 +33,23 @@ graph_config = {
} }
# ************************************************ # ************************************************
# Create the XmlScraperGraph instance and run it # Create the JSONScraperGraph instance and run it
# ************************************************ # ************************************************
smart_scraper_graph = JsonScraperGraph( json_scraper_graph = JSONScraperGraph(
prompt="List me all the authors, title and genres of the books", prompt="List me all the authors, title and genres of the books",
source=text, # Pass the content of the file, not the file object source=text, # Pass the content of the file, not the file object
config=graph_config config=graph_config
) )
result = smart_scraper_graph.run() result = json_scraper_graph.run()
print(result) print(result)
# ************************************************ # ************************************************
# Get graph execution info # Get graph execution info
# ************************************************ # ************************************************
graph_exec_info = smart_scraper_graph.get_execution_info() graph_exec_info = json_scraper_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info)) print(prettify_exec_info(graph_exec_info))
# Save to json or csv # Save to json or csv

View File

@ -0,0 +1 @@
{"top_5_eyeliner_products_for_gift": [{"product_name": "Tarte Double Take Eyeliner", "type": "Liquid, Gel", "price": "$26", "link": "https://www.sephora.com/product/double-take-eyeliner-P421701"}, {"product_name": "AppleDoll Velvet Liner", "type": "Liquid", "price": "$22", "link": "https://www.appledoll.com/products/velvet-liner"}, {"product_name": "Rare Beauty Perfect Strokes Gel Eyeliner", "type": "Gel", "price": "$19", "link": "https://www.sephora.com/product/perfect-strokes-gel-eyeliner-P468000"}, {"product_name": "Laura Mercier Caviar Tightline Eyeliner", "type": "Gel", "price": "$29", "link": "https://www.sephora.com/product/caviar-tightline-eyeliner-P448800"}, {"product_name": "Ilia Clean Line Liquid Eyeliner", "type": "Liquid", "price": "$28", "link": "https://www.amazon.com/ILIA-Clean-Line-Liquid-Eyeliner/dp/B08Z7JZQZP"}, {"brand": "Tom Ford", "product_name": "Eye Defining Pen", "price": "$62", "type": "Liquid", "colors": 1, "retailer": "Nordstrom"}, {"brand": "Fenty Beauty", "product_name": "Flyliner", "price": "$24", "type": "Liquid", "colors": 2, "retailer": "Sephora"}, {"brand": "Lanc\u00f4me", "product_name": "Le Crayon Kh\u00f4l Smoky Eyeliner", "price": "$28", "type": "Kohl", "colors": 2, "retailer": "Macy's"}, {"brand": "Jillian Dempsey", "product_name": "Kh\u00f4l Eyeliner", "price": "$20", "type": "Kohl", "colors": 6, "retailer": "Amazon"}, {"brand": "R\u00f3en", "product_name": "Eyeline Define Eyeliner Pencil", "price": "$26", "type": "Kohl", "colors": 4, "retailer": "Credo Beauty"}]}

View File

@ -1,10 +1,10 @@
""" """
Basic example of scraping pipeline using XmlScraperGraph from XML documents Basic example of scraping pipeline using XMLScraperGraph from XML documents
""" """
import os import os
from dotenv import load_dotenv from dotenv import load_dotenv
from scrapegraphai.graphs import XmlScraperGraph from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
load_dotenv() load_dotenv()
@ -33,23 +33,23 @@ graph_config = {
} }
# ************************************************ # ************************************************
# Create the XmlScraperGraph instance and run it # Create the XMLScraperGraph instance and run it
# ************************************************ # ************************************************
smart_scraper_graph = XmlScraperGraph( xml_scraper_graph = XMLScraperGraph(
prompt="List me all the authors, title and genres of the books", prompt="List me all the authors, title and genres of the books",
source=text, # Pass the content of the file, not the file object source=text, # Pass the content of the file, not the file object
config=graph_config config=graph_config
) )
result = smart_scraper_graph.run() result = xml_scraper_graph.run()
print(result) print(result)
# ************************************************ # ************************************************
# Get graph execution info # Get graph execution info
# ************************************************ # ************************************************
graph_exec_info = smart_scraper_graph.get_execution_info() graph_exec_info = xml_scraper_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info)) print(prettify_exec_info(graph_exec_info))
# Save to json or csv # Save to json or csv

View File

@ -6,5 +6,5 @@ from .smart_scraper_graph import SmartScraperGraph
from .speech_graph import SpeechGraph from .speech_graph import SpeechGraph
from .search_graph import SearchGraph from .search_graph import SearchGraph
from .script_creator_graph import ScriptCreatorGraph from .script_creator_graph import ScriptCreatorGraph
from .xml_scraper_graph import XmlScraperGraph from .xml_scraper_graph import XMLScraperGraph
from .json_scraper_graph import JsonScraperGraph from .json_scraper_graph import JSONScraperGraph

View File

@ -11,7 +11,7 @@ from ..nodes import (
from .abstract_graph import AbstractGraph from .abstract_graph import AbstractGraph
class JsonScraperGraph(AbstractGraph): class JSONScraperGraph(AbstractGraph):
""" """
SmartScraper is a comprehensive web scraping tool that automates the process of extracting SmartScraper is a comprehensive web scraping tool that automates the process of extracting
information from web pages using a natural language model to interpret and answer prompts. information from web pages using a natural language model to interpret and answer prompts.

View File

@ -11,7 +11,7 @@ from ..nodes import (
from .abstract_graph import AbstractGraph from .abstract_graph import AbstractGraph
class XmlScraperGraph(AbstractGraph): class XMLScraperGraph(AbstractGraph):
""" """
SmartScraper is a comprehensive web scraping tool that automates the process of extracting SmartScraper is a comprehensive web scraping tool that automates the process of extracting
information from web pages using a natural language model to interpret and answer prompts. information from web pages using a natural language model to interpret and answer prompts.