Skip to content

Python scraper based on AI

add robot node

VinciGit00a4700bfc75cc
diff --git a/examples/single_node/robot_node.py b/examples/single_node/robot_node.py
index 257c4efb..d824400a 100644
--- a/examples/single_node/robot_node.py
+++ b/examples/single_node/robot_node.py
@@ -11,7 +11,7 @@ from scrapegraphai.nodes import RobotsNode
graph_config = {
"llm": {
- "model": "ollama/llama3",
+ "model_name": "ollama/llama3",
"temperature": 0,
"streaming": True
},
diff --git a/poetry.lock b/poetry.lock
index 4e8d9a33..70b6a265 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -134,13 +134,13 @@ files = [
[[package]]
name = "anthropic"
-version = "0.25.8"
+version = "0.25.9"
description = "The official Python library for the anthropic API"
optional = false
python-versions = ">=3.7"
files = [
- {file = "anthropic-0.25.8-py3-none-any.whl", hash = "sha256:c7a0091916eb22a5e0012b725f5492779eedfcad2da8dc906082e1db7596a65c"},
- {file = "anthropic-0.25.8.tar.gz", hash = "sha256:93f6063e96d5dbeaa172edc177762f630e55b2f81595cedb760278b95a2dd03e"},
+ {file = "anthropic-0.25.9-py3-none-any.whl", hash = "sha256:d0b17d442160356a531593b237de55d3125cc6fa708f1268c214107e61c81c57"},
+ {file = "anthropic-0.25.9.tar.gz", hash = "sha256:a4ec810b1cfbf3340af99b6f5bf599a83d66986e0f572a5f3bc4ebcab284f629"},
]
[package.dependencies]
@@ -245,17 +245,17 @@ lxml = ["lxml"]
[[package]]
name = "boto3"
-version = "1.34.104"
+version = "1.34.105"
description = "The AWS SDK for Python"
optional = false
python-versions = ">=3.8"
files = [
- {file = "boto3-1.34.104-py3-none-any.whl", hash = "sha256:bec91a3bca63320e5f68a25b5eaa7bab65e35bb9253a544875c2e03679f1d5fb"},
- {file = "boto3-1.34.104.tar.gz", hash = "sha256:5b37c8f4ea6f408147994a6e230c49ca755da57f5964ccea8b8fd4ff5f11759e"},
+ {file = "boto3-1.34.105-py3-none-any.whl", hash = "sha256:b633e8fbf7145bdb995ce68a27d096bb89fd393185b0e773418d81cd78db5a03"},
+ {file = "boto3-1.34.105.tar.gz", hash = "sha256:f2c11635be0de7b7c06eb606ece1add125e02d6ed521592294a0a21af09af135"},
]
[package.dependencies]
-botocore = ">=1.34.104,<1.35.0"
+botocore = ">=1.34.105,<1.35.0"
jmespath = ">=0.7.1,<2.0.0"
s3transfer = ">=0.10.0,<0.11.0"
@@ -264,13 +264,13 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"]
[[package]]
name = "botocore"
-version = "1.34.104"
+version = "1.34.105"
description = "Low-level, data-driven core of boto 3."
optional = false
python-versions = ">=3.8"
files = [
- {file = "botocore-1.34.104-py3-none-any.whl", hash = "sha256:b68ed482e9b4c313129c9948af5a91d0e84840558e6d232a1a27ab0b9733e5b9"},
- {file = "botocore-1.34.104.tar.gz", hash = "sha256:fe36dd3cea4160fbbe27dc1cf89cb7018234350555a26933b2977947052a346a"},
+ {file = "botocore-1.34.105-py3-none-any.whl", hash = "sha256:a459d060b541beecb50681e6e8a39313cca981e146a59ba7c5229d62f631a016"},
+ {file = "botocore-1.34.105.tar.gz", hash = "sha256:727d5d3e800ac8b705fca6e19b6fefa1e728a81d62a712df9bd32ed0117c740b"},
]
[package.dependencies]
@@ -1861,13 +1861,13 @@ files = [
[[package]]
name = "openai"
-version = "1.29.0"
+version = "1.30.1"
description = "The official Python library for the openai API"
optional = false
python-versions = ">=3.7.1"
files = [
- {file = "openai-1.29.0-py3-none-any.whl", hash = "sha256:c61cd12376c84362d406341f9e2f9a9d6b81c082b133b44484dc0f43954496b1"},
- {file = "openai-1.29.0.tar.gz", hash = "sha256:d5a769f485610cff8bae14343fa45a8b1d346be3d541fa5b28ccd040dbc8baf8"},
+ {file = "openai-1.30.1-py3-none-any.whl", hash = "sha256:c9fb3c3545c118bbce8deb824397b9433a66d0d0ede6a96f7009c95b76de4a46"},
+ {file = "openai-1.30.1.tar.gz", hash = "sha256:4f85190e577cba0b066e1950b8eb9b11d25bc7ebcc43a86b326ce1bfa564ec74"},
]
[package.dependencies]
diff --git a/scrapegraphai/nodes/robots_node.py b/scrapegraphai/nodes/robots_node.py
index 29b71800..cdbd3e3a 100644
--- a/scrapegraphai/nodes/robots_node.py
+++ b/scrapegraphai/nodes/robots_node.py
@@ -61,10 +61,9 @@ class RobotsNode(BaseNode):
ValueError: If the website is not scrapeable based on the robots.txt file and
scraping is not enforced.
"""
- logger = get_logger("robots node")
if self.verbose:
- logger.info(f"--- Executing {self.node_name} Node ---")
+ self.logger.info(f"--- Executing {self.node_name} Node ---")
# Interpret input keys based on the provided input expression
input_keys = self.get_input_keys(state)
@@ -97,12 +96,12 @@ class RobotsNode(BaseNode):
base_url = f"{parsed_url.scheme}://{parsed_url.netloc}"
loader = AsyncChromiumLoader(f"{base_url}/robots.txt")
document = loader.load()
- if "ollama" in self.llm_model.model_name:
- self.llm_model.model_name = self.llm_model.model_name.split("/")[-1]
- model = self.llm_model.model_name.split("/")[-1]
+ if "ollama" in self.llm_model["model_name"]:
+ self.llm_model["model_name"] = self.llm_model["model_name"].split("/")[-1]
+ model = self.llm_model["model_name"].split("/")[-1]
else:
- model = self.llm_model.model_name
+ model = self.llm_model["model_name"]
try:
agent = robots_dictionary[model]
diff --git a/tests/nodes/fetch_node_test.py b/tests/nodes/fetch_node_test.py
index a67f3dbb..47b8b7ee 100644
--- a/tests/nodes/fetch_node_test.py
+++ b/tests/nodes/fetch_node_test.py
@@ -1,19 +1,11 @@
-"""
-Module for testinh fetch_node
-"""
+import os
import pytest
from scrapegraphai.nodes import FetchNode
-
-def setup():
+def test_fetch_node_html():
"""
- setup
+ Run the tests
"""
- # ************************************************
- # Define the node
- # ************************************************
-
fetch_node = FetchNode(
input="url | local_dir",
output=["doc"],
@@ -22,21 +14,94 @@ def setup():
}
)
- return fetch_node
+ state = {
+ "url": "https://twitter.com/home"
+ }
-# ************************************************
-# Test the node
-# ************************************************
+ result = fetch_node.execute(state)
+ assert result is not None
-def test_fetch_node(setup):
+def test_fetch_node_json():
"""
Run the tests
"""
- state = {
- "url": "https://twitter.com/home"
+ FILE_NAME_JSON = "inputs/example.json"
+ curr_dir = os.path.dirname(os.path.realpath(__file__))
+ file_path_json = os.path.join(curr_dir, FILE_NAME_JSON)
+
+ state_json = {
+ "json": file_path_json
+ }
+
+ fetch_node_json = FetchNode(
+ input="json",
+ output=["doc"],
+ )
+
+ result_json = fetch_node_json.execute(state_json)
+
+ assert result_json is not None
+
+def test_fetch_node_xml():
+ """
+ Run the tests
+ """
+ FILE_NAME_XML = "inputs/books.xml"
+ curr_dir = os.path.dirname(os.path.realpath(__file__))
+ file_path_xml = os.path.join(curr_dir, FILE_NAME_XML)
+
+ state_xml = {
+ "xml": file_path_xml
}
- result = setup.execute(state)
+ fetch_node_xml = FetchNode(
+ input="xml",
+ output=["doc"],
+ )
- assert result is not None
+ result_xml = fetch_node_xml.execute(state_xml)
+
+ assert result_xml is not None
+
+def test_fetch_node_csv():
+ """
+ Run the tests
+ """
+ FILE_NAME_CSV = "inputs/username.csv"
+ curr_dir = os.path.dirname(os.path.realpath(__file__))
+ file_path_csv = os.path.join(curr_dir, FILE_NAME_CSV)
+
+ state_csv = {
+ "csv": file_path_csv # Definire un dizionario con la chiave "csv" e il valore come percorso del file CSV
+ }
+
+ fetch_node_csv = FetchNode(
+ input="csv",
+ output=["doc"],
+ )
+
+ result_csv = fetch_node_csv.execute(state_csv)
+
+ assert result_csv is not None
+
+def test_fetch_node_txt():
+ """
+ Run the tests
+ """
+ FILE_NAME_TXT = "inputs/plain_html_example.txt"
+ curr_dir = os.path.dirname(os.path.realpath(__file__))
+ file_path_txt = os.path.join(curr_dir, FILE_NAME_TXT)
+
+ state_txt = {
+ "txt": file_path_txt # Definire un dizionario con la chiave "txt" e il valore come percorso del file TXT
+ }
+
+ fetch_node_txt = FetchNode(
+ input="txt",
+ output=["doc"],
+ )
+
+ result_txt = fetch_node_txt.execute(state_txt)
+
+ assert result_txt is not None
diff --git a/tests/nodes/inputs/books.xml b/tests/nodes/inputs/books.xml
new file mode 100644
index 00000000..e3d1fe87
--- /dev/null
+++ b/tests/nodes/inputs/books.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0"?>
+<catalog>
+ <book id="bk101">
+ <author>Gambardella, Matthew</author>
+ <title>XML Developer's Guide</title>
+ <genre>Computer</genre>
+ <price>44.95</price>
+ <publish_date>2000-10-01</publish_date>
+ <description>An in-depth look at creating applications
+ with XML.</description>
+ </book>
+ <book id="bk102">
+ <author>Ralls, Kim</author>
+ <title>Midnight Rain</title>
+ <genre>Fantasy</genre>
+ <price>5.95</price>
+ <publish_date>2000-12-16</publish_date>
+ <description>A former architect battles corporate zombies,
+ an evil sorceress, and her own childhood to become queen
+ of the world.</description>
+ </book>
+ <book id="bk103">
+ <author>Corets, Eva</author>
+ <title>Maeve Ascendant</title>
+ <genre>Fantasy</genre>
+ <price>5.95</price>
+ <publish_date>2000-11-17</publish_date>
+ <description>After the collapse of a nanotechnology
+ society in England, the young survivors lay the
+ foundation for a new society.</description>
+ </book>
+ <book id="bk104">
+ <author>Corets, Eva</author>
+ <title>Oberon's Legacy</title>
+ <genre>Fantasy</genre>
+ <price>5.95</price>
+ <publish_date>2001-03-10</publish_date>
+ <description>In post-apocalypse England, the mysterious
+ agent known only as Oberon helps to create a new life
+ for the inhabitants of London. Sequel to Maeve
+ Ascendant.</description>
+ </book>
+ <book id="bk105">
+ <author>Corets, Eva</author>
+ <title>The Sundered Grail</title>
+ <genre>Fantasy</genre>
+ <price>5.95</price>
+ <publish_date>2001-09-10</publish_date>
+ <description>The two daughters of Maeve, half-sisters,
+ battle one another for control of England. Sequel to
+ Oberon's Legacy.</description>
+ </book>
+ <book id="bk106">
+ <author>Randall, Cynthia</author>
+ <title>Lover Birds</title>
+ <genre>Romance</genre>
+ <price>4.95</price>
+ <publish_date>2000-09-02</publish_date>
+ <description>When Carla meets Paul at an ornithology
+ conference, tempers fly as feathers get ruffled.</description>
+ </book>
+ <book id="bk107">
+ <author>Thurman, Paula</author>
+ <title>Splish Splash</title>
+ <genre>Romance</genre>
+ <price>4.95</price>
+ <publish_date>2000-11-02</publish_date>
+ <description>A deep sea diver finds true love twenty
+ thousand leagues beneath the sea.</description>
+ </book>
+ <book id="bk108">
+ <author>Knorr, Stefan</author>
+ <title>Creepy Crawlies</title>
+ <genre>Horror</genre>
+ <price>4.95</price>
+ <publish_date>2000-12-06</publish_date>
+ <description>An anthology of horror stories about roaches,
+ centipedes, scorpions and other insects.</description>
+ </book>
+ <book id="bk109">
+ <author>Kress, Peter</author>
+ <title>Paradox Lost</title>
+ <genre>Science Fiction</genre>
+ <price>6.95</price>
+ <publish_date>2000-11-02</publish_date>
+ <description>After an inadvertant trip through a Heisenberg
+ Uncertainty Device, James Salway discovers the problems
+ of being quantum.</description>
+ </book>
+ <book id="bk110">
+ <author>O'Brien, Tim</author>
+ <title>Microsoft .NET: The Programming Bible</title>
+ <genre>Computer</genre>
+ <price>36.95</price>
+ <publish_date>2000-12-09</publish_date>
+ <description>Microsoft's .NET initiative is explored in
+ detail in this deep programmer's reference.</description>
+ </book>
+ <book id="bk111">
+ <author>O'Brien, Tim</author>
+ <title>MSXML3: A Comprehensive Guide</title>
+ <genre>Computer</genre>
+ <price>36.95</price>
+ <publish_date>2000-12-01</publish_date>
+ <description>The Microsoft MSXML3 parser is covered in
+ detail, with attention to XML DOM interfaces, XSLT processing,
+ SAX and more.</description>
+ </book>
+ <book id="bk112">
+ <author>Galos, Mike</author>
+ <title>Visual Studio 7: A Comprehensive Guide</title>
+ <genre>Computer</genre>
+ <price>49.95</price>
+ <publish_date>2001-04-16</publish_date>
+ <description>Microsoft Visual Studio 7 is explored in depth,
+ looking at how Visual Basic, Visual C++, C#, and ASP+ are
+ integrated into a comprehensive development
+ environment.</description>
+ </book>
+</catalog>
\ No newline at end of file
diff --git a/tests/nodes/inputs/example.json b/tests/nodes/inputs/example.json
new file mode 100644
index 00000000..2263184c
--- /dev/null
+++ b/tests/nodes/inputs/example.json
@@ -0,0 +1,182 @@
+{
+ "kind":"youtube#searchListResponse",
+ "etag":"q4ibjmYp1KA3RqMF4jFLl6PBwOg",
+ "nextPageToken":"CAUQAA",
+ "regionCode":"NL",
+ "pageInfo":{
+ "totalResults":1000000,
+ "resultsPerPage":5
+ },
+ "items":[
+ {
+ "kind":"youtube#searchResult",
+ "etag":"QCsHBifbaernVCbLv8Cu6rAeaDQ",
+ "id":{
+ "kind":"youtube#video",
+ "videoId":"TvWDY4Mm5GM"
+ },
+ "snippet":{
+ "publishedAt":"2023-07-24T14:15:01Z",
+ "channelId":"UCwozCpFp9g9x0wAzuFh0hwQ",
+ "title":"3 Football Clubs Kylian Mbappe Should Avoid Signing ✍️❌⚽️ #football #mbappe #shorts",
+ "description":"",
+ "thumbnails":{
+ "default":{
+ "url":"https://i.ytimg.com/vi/TvWDY4Mm5GM/default.jpg",
+ "width":120,
+ "height":90
+ },
+ "medium":{
+ "url":"https://i.ytimg.com/vi/TvWDY4Mm5GM/mqdefault.jpg",
+ "width":320,
+ "height":180
+ },
+ "high":{
+ "url":"https://i.ytimg.com/vi/TvWDY4Mm5GM/hqdefault.jpg",
+ "width":480,
+ "height":360
+ }
+ },
+ "channelTitle":"FC Motivate",
+ "liveBroadcastContent":"none",
+ "publishTime":"2023-07-24T14:15:01Z"
+ }
+ },
+ {
+ "kind":"youtube#searchResult",
+ "etag":"0NG5QHdtIQM_V-DBJDEf-jK_Y9k",
+ "id":{
+ "kind":"youtube#video",
+ "videoId":"aZM_42CcNZ4"
+ },
+ "snippet":{
+ "publishedAt":"2023-07-24T16:09:27Z",
+ "channelId":"UCM5gMM_HqfKHYIEJ3lstMUA",
+ "title":"Which Football Club Could Cristiano Ronaldo Afford To Buy? 💰",
+ "description":"Sign up to Sorare and get a FREE card: https://sorare.pxf.io/NellisShorts Give Soraredata a go for FREE: ...",
+ "thumbnails":{
+ "default":{
+ "url":"https://i.ytimg.com/vi/aZM_42CcNZ4/default.jpg",
+ "width":120,
+ "height":90
+ },
+ "medium":{
+ "url":"https://i.ytimg.com/vi/aZM_42CcNZ4/mqdefault.jpg",
+ "width":320,
+ "height":180
+ },
+ "high":{
+ "url":"https://i.ytimg.com/vi/aZM_42CcNZ4/hqdefault.jpg",
+ "width":480,
+ "height":360
+ }
+ },
+ "channelTitle":"John Nellis",
+ "liveBroadcastContent":"none",
+ "publishTime":"2023-07-24T16:09:27Z"
+ }
+ },
+ {
+ "kind":"youtube#searchResult",
+ "etag":"WbBz4oh9I5VaYj91LjeJvffrBVY",
+ "id":{
+ "kind":"youtube#video",
+ "videoId":"wkP3XS3aNAY"
+ },
+ "snippet":{
+ "publishedAt":"2023-07-24T16:00:50Z",
+ "channelId":"UC4EP1dxFDPup_aFLt0ElsDw",
+ "title":"PAULO DYBALA vs THE WORLD'S LONGEST FREEKICK WALL",
+ "description":"Can Paulo Dybala curl a football around the World's longest free kick wall? We met up with the World Cup winner and put him to ...",
+ "thumbnails":{
+ "default":{
+ "url":"https://i.ytimg.com/vi/wkP3XS3aNAY/default.jpg",
+ "width":120,
+ "height":90
+ },
+ "medium":{
+ "url":"https://i.ytimg.com/vi/wkP3XS3aNAY/mqdefault.jpg",
+ "width":320,
+ "height":180
+ },
+ "high":{
+ "url":"https://i.ytimg.com/vi/wkP3XS3aNAY/hqdefault.jpg",
+ "width":480,
+ "height":360
+ }
+ },
+ "channelTitle":"Shoot for Love",
+ "liveBroadcastContent":"none",
+ "publishTime":"2023-07-24T16:00:50Z"
+ }
+ },
+ {
+ "kind":"youtube#searchResult",
+ "etag":"juxv_FhT_l4qrR05S1QTrb4CGh8",
+ "id":{
+ "kind":"youtube#video",
+ "videoId":"rJkDZ0WvfT8"
+ },
+ "snippet":{
+ "publishedAt":"2023-07-24T10:00:39Z",
+ "channelId":"UCO8qj5u80Ga7N_tP3BZWWhQ",
+ "title":"TOP 10 DEFENDERS 2023",
+ "description":"SoccerKingz https://soccerkingz.nl Use code: 'ILOVEHOF' to get 10% off. TOP 10 DEFENDERS 2023 Follow us! • Instagram ...",
+ "thumbnails":{
+ "default":{
+ "url":"https://i.ytimg.com/vi/rJkDZ0WvfT8/default.jpg",
+ "width":120,
+ "height":90
+ },
+ "medium":{
+ "url":"https://i.ytimg.com/vi/rJkDZ0WvfT8/mqdefault.jpg",
+ "width":320,
+ "height":180
+ },
+ "high":{
+ "url":"https://i.ytimg.com/vi/rJkDZ0WvfT8/hqdefault.jpg",
+ "width":480,
+ "height":360
+ }
+ },
+ "channelTitle":"Home of Football",
+ "liveBroadcastContent":"none",
+ "publishTime":"2023-07-24T10:00:39Z"
+ }
+ },
+ {
+ "kind":"youtube#searchResult",
+ "etag":"wtuknXTmI1txoULeH3aWaOuXOow",
+ "id":{
+ "kind":"youtube#video",
+ "videoId":"XH0rtu4U6SE"
+ },
+ "snippet":{
+ "publishedAt":"2023-07-21T16:30:05Z",
+ "channelId":"UCwozCpFp9g9x0wAzuFh0hwQ",
+ "title":"3 Things You Didn't Know About Erling Haaland ⚽️🇳🇴 #football #haaland #shorts",
+ "description":"",
+ "thumbnails":{
+ "default":{
+ "url":"https://i.ytimg.com/vi/XH0rtu4U6SE/default.jpg",
+ "width":120,
+ "height":90
+ },
+ "medium":{
+ "url":"https://i.ytimg.com/vi/XH0rtu4U6SE/mqdefault.jpg",
+ "width":320,
+ "height":180
+ },
+ "high":{
+ "url":"https://i.ytimg.com/vi/XH0rtu4U6SE/hqdefault.jpg",
+ "width":480,
+ "height":360
+ }
+ },
+ "channelTitle":"FC Motivate",
+ "liveBroadcastContent":"none",
+ "publishTime":"2023-07-21T16:30:05Z"
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/tests/nodes/inputs/plain_html_example.txt b/tests/nodes/inputs/plain_html_example.txt
new file mode 100644
index 00000000..78f814ae
--- /dev/null
+++ b/tests/nodes/inputs/plain_html_example.txt
@@ -0,0 +1,105 @@
+<body class="fixed-top-nav " style="padding-top: 57px;">
+ <header>
+ <nav id="navbar" class="navbar navbar-light navbar-expand-sm fixed-top">
+ <div class="container">
+ <a class="navbar-brand title font-weight-lighter" href="/"><span class="font-weight-bold">Marco&nbsp;</span>Perini</a> <button class="navbar-toggler collapsed ml-auto" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar top-bar"></span> <span class="icon-bar middle-bar"></span> <span class="icon-bar bottom-bar"></span> </button>
+ <div class="collapse navbar-collapse text-right" id="navbarNav">
+ <ul class="navbar-nav ml-auto flex-nowrap">
+ <li class="nav-item "> <a class="nav-link" href="/">About</a> </li>
+ <li class="nav-item dropdown active">
+ <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Projects<span class="sr-only">(current)</span></a>
+ <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
+ <a class="dropdown-item" href="/projects/">Projects</a>
+ <div class="dropdown-divider"></div>
+ <a class="dropdown-item" href="/competitions/">Competitions</a>
+ </div>
+ </li>
+ <li class="nav-item "> <a class="nav-link" href="/cv/">CV</a> </li>
+ <li class="toggle-container"> <button id="light-toggle" title="Change theme"> <i class="fa-solid fa-moon"></i> <i class="fa-solid fa-sun"></i> </button> </li>
+ </ul>
+ </div>
+ </div>
+ </nav>
+ <progress id="progress" value="0" max="284" style="top: 57px;">
+ <div class="progress-container"> <span class="progress-bar"></span> </div>
+ </progress>
+ </header>
+ <div class="container mt-5">
+ <div class="post">
+ <header class="post-header">
+ <h1 class="post-title">Projects</h1>
+ <p class="post-description"></p>
+ </header>
+ <article>
+ <div class="projects">
+ <div class="grid" style="position: relative; height: 861.992px;">
+ <div class="grid-sizer"></div>
+ <div class="grid-item" style="position: absolute; left: 0px; top: 0px;">
+ <a href="/projects/rotary-pendulum-rl/">
+ <div class="card hoverable">
+ <figure>
+ <picture> <img src="/assets/img/rotary_pybullet.jpg" width="auto" height="auto" alt="project thumbnail" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"> </picture>
+ </figure>
+ <div class="card-body">
+ <h4 class="card-title">Rotary Pendulum RL</h4>
+ <p class="card-text">Open Source project aimed at controlling a real life rotary pendulum using RL algorithms</p>
+ <div class="row ml-1 mr-1 p-0"> </div>
+ </div>
+ </div>
+ </a>
+ </div>
+ <div class="grid-sizer"></div>
+ <div class="grid-item" style="position: absolute; left: 260px; top: 0px;">
+ <a href="https://github.com/PeriniM/DQN-SwingUp" rel="external nofollow noopener" target="_blank">
+ <div class="card hoverable">
+ <figure>
+ <picture> <img src="/assets/img/value-policy-heatmaps.jpg" width="auto" height="auto" alt="project thumbnail" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"> </picture>
+ </figure>
+ <div class="card-body">
+ <h4 class="card-title">DQN Implementation from scratch</h4>
+ <p class="card-text">Developed a Deep Q-Network algorithm to train a simple and double pendulum</p>
+ <div class="row ml-1 mr-1 p-0"> </div>
+ </div>
+ </div>
+ </a>
+ </div>
+ <div class="grid-sizer"></div>
+ <div class="grid-item" style="position: absolute; left: 0px; top: 447.414px;">
+ <a href="https://github.com/PeriniM/Multi-Agents-HAED" rel="external nofollow noopener" target="_blank">
+ <div class="card hoverable">
+ <figure>
+ <picture> <img src="/assets/img/multi_agents_haed.gif" width="auto" height="auto" alt="project thumbnail" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"> </picture>
+ </figure>
+ <div class="card-body">
+ <h4 class="card-title">Multi Agents HAED</h4>
+ <p class="card-text">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.</p>
+ <div class="row ml-1 mr-1 p-0"> </div>
+ </div>
+ </div>
+ </a>
+ </div>
+ <div class="grid-sizer"></div>
+ <div class="grid-item" style="position: absolute; left: 260px; top: 370.172px;">
+ <a href="/projects/wireless-esc-drone/">
+ <div class="card hoverable">
+ <figure>
+ <picture> <img src="/assets/img/wireless_esc.gif" width="auto" height="auto" alt="project thumbnail" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"> </picture>
+ </figure>
+ <div class="card-body">
+ <h4 class="card-title">Wireless ESC for Modular Drones</h4>
+ <p class="card-text">Modular drone architecture proposal and proof of concept. The project received maximum grade.</p>
+ <div class="row ml-1 mr-1 p-0"> </div>
+ </div>
+ </div>
+ </a>
+ </div>
+ </div>
+ </div>
+ </article>
+ </div>
+ </div>
+ <footer class="fixed-bottom">
+ <div class="container mt-0"> © Copyright 2023 Marco Perini. Powered by <a href="https://jekyllrb.com/" target="_blank" rel="external nofollow noopener">Jekyll</a> with <a href="https://github.com/alshedivat/al-folio" rel="external nofollow noopener" target="_blank">al-folio</a> theme. Hosted by <a href="https://pages.github.com/" target="_blank" rel="external nofollow noopener">GitHub Pages</a>. </div>
+ </footer>
+ <div class="hiddendiv common"></div>
+</body>
\ No newline at end of file
diff --git a/tests/nodes/inputs/username.csv b/tests/nodes/inputs/username.csv
new file mode 100644
index 00000000..006ac8e6
--- /dev/null
+++ b/tests/nodes/inputs/username.csv
@@ -0,0 +1,7 @@
+Username; Identifier;First name;Last name
+booker12;9012;Rachel;Booker
+grey07;2070;Laura;Grey
+johnson81;4081;Craig;Johnson
+jenkins46;9346;Mary;Jenkins
+smith79;5079;Jamie;Smith
+
diff --git a/tests/nodes/robot_node_test.py b/tests/nodes/robot_node_test.py
index 084522c4..5818b91c 100644
--- a/tests/nodes/robot_node_test.py
+++ b/tests/nodes/robot_node_test.py
@@ -1,15 +1,11 @@
-"""
-Module for testinh robot_node
-"""
import pytest
from scrapegraphai.models import Ollama
from scrapegraphai.nodes import RobotsNode
-
@pytest.fixture
def setup():
"""
- setup
+ Setup
"""
# ************************************************
# Define the configuration for the graph
@@ -17,7 +13,7 @@ def setup():
graph_config = {
"llm": {
- "model": "ollama/llama3",
+ "model_name": "ollama/llama3", # Modifica il nome dell'attributo da "model_name" a "model"
"temperature": 0,
"streaming": True
},
@@ -32,26 +28,31 @@ def setup():
robots_node = RobotsNode(
input="url",
output=["is_scrapable"],
- node_config={"llm": llm_model,
+ node_config={"llm_model": llm_model,
"headless": False
}
)
- return robots_node
+ # ************************************************
+ # Define the initial state
+ # ************************************************
+
+ initial_state = {
+ "url": "https://twitter.com/home"
+ }
+
+ return robots_node, initial_state
# ************************************************
# Test the node
# ************************************************
-
def test_robots_node(setup):
"""
Run the tests
"""
- state = {
- "url": "https://twitter.com/home"
- }
+ robots_node, initial_state = setup # Estrai l'oggetto RobotsNode e lo stato iniziale dalla tupla
- result = setup.execute(state)
+ result = robots_node.execute(initial_state)
assert result is not None
diff --git a/tests/nodes/search_link_node_test.py b/tests/nodes/search_link_node_test.py
new file mode 100644
index 00000000..9c00c8dd
--- /dev/null
+++ b/tests/nodes/search_link_node_test.py
@@ -0,0 +1,64 @@
+import pytest
+from scrapegraphai.models import Ollama
+from scrapegraphai.nodes import SearchLinkNode
+
+def setup():
+ """
+ Setup
+ """
+ # ************************************************
+ # Define the configuration for the graph
+ # ************************************************
+
+ graph_config = {
+ "llm": {
+ "model_name": "ollama/llama3", # Modifica il nome dell'attributo da "model_name" a "model"
+ "temperature": 0,
+ "streaming": True
+ },
+ }
+
+ # ************************************************
+ # Define the node
+ # ************************************************
+
+ llm_model = Ollama(graph_config["llm"])
+
+ search_link_node = SearchLinkNode(
+ input=["user_prompt", "parsed_content_chunks"],
+ output=["relevant_links"],
+ node_config={"llm_model": llm_model,
+ "verbose": False
+ }
+ )
+
+ # ************************************************
+ # Define the initial state
+ # ************************************************
+
+ initial_state = {
+ "user_prompt": "Example user prompt",
+ "parsed_content_chunks": [
+ {"page_content": "Example page content 1"},
+ {"page_content": "Example page content 2"},
+ # Add more example page content dictionaries as needed
+ ]
+ }
+
+ return search_link_node, initial_state
+
+# ************************************************
+# Test the node
+# ************************************************
+
+def test_search_link_node(setup):
+ """
+ Run the tests
+ """
+ search_link_node, initial_state = setup # Extract the SearchLinkNode object and the initial state from the tuple
+
+ result = search_link_node.execute(initial_state)
+
+ # Assert that the result is not None
+ assert result is not None