mirror of
https://github.com/VinciGit00/Scrapegraph-ai.git
synced 2026-07-09 21:19:20 +08:00
Merge branch 'main' into pre/beta
This commit is contained in:
commit
470f9e2dc8
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@ -12,4 +12,4 @@ lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cl
|
||||
polar: # Replace with a single Polar username
|
||||
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
|
||||
thanks_dev: # Replace with a single thanks.dev username
|
||||
custom:
|
||||
custom:
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/custom.md
vendored
2
.github/ISSUE_TEMPLATE/custom.md
vendored
@ -6,5 +6,3 @@ labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
26
.github/workflows/release.yml
vendored
26
.github/workflows/release.yml
vendored
@ -19,21 +19,21 @@ jobs:
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v3
|
||||
|
||||
|
||||
- name: Install Node Env
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.1.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
|
||||
- name: Build and validate package
|
||||
run: |
|
||||
uv venv
|
||||
@ -44,10 +44,10 @@ jobs:
|
||||
uv build
|
||||
uv pip install --upgrade pkginfo==1.12.0 twine==6.0.1 # Upgrade pkginfo and install twine
|
||||
python -m twine check dist/*
|
||||
|
||||
|
||||
- name: Debug Dist Directory
|
||||
run: ls -al dist
|
||||
|
||||
|
||||
- name: Cache build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
@ -59,7 +59,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
environment: development
|
||||
if: >
|
||||
if: >
|
||||
github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/pre/beta') ||
|
||||
(github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged &&
|
||||
(github.event.pull_request.base.ref == 'main' || github.event.pull_request.base.ref == 'pre/beta'))
|
||||
@ -74,23 +74,23 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
|
||||
- name: Restore build artifacts
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ./dist
|
||||
key: ${{ runner.os }}-build-${{ github.sha }}
|
||||
|
||||
|
||||
- name: Semantic Release
|
||||
uses: cycjimmy/semantic-release-action@v4.1.0
|
||||
with:
|
||||
semantic_version: 23
|
||||
extra_plugins: |
|
||||
semantic-release-pypi@3
|
||||
@semantic-release/git
|
||||
@semantic-release/commit-analyzer@12
|
||||
@semantic-release/release-notes-generator@13
|
||||
@semantic-release/github@10
|
||||
@semantic-release/git
|
||||
@semantic-release/commit-analyzer@12
|
||||
@semantic-release/release-notes-generator@13
|
||||
@semantic-release/github@10
|
||||
@semantic-release/changelog@6
|
||||
conventional-changelog-conventionalcommits@7
|
||||
env:
|
||||
|
||||
36
.readthedocs.yaml
Normal file
36
.readthedocs.yaml
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
# Read the Docs configuration file for Sphinx projects
|
||||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||
|
||||
# Required
|
||||
version: 2
|
||||
|
||||
# Set the OS, Python version and other tools you might need
|
||||
build:
|
||||
os: ubuntu-22.04
|
||||
tools:
|
||||
python: "3.12"
|
||||
# You can also specify other tool versions:
|
||||
# nodejs: "20"
|
||||
# rust: "1.70"
|
||||
# golang: "1.20"
|
||||
|
||||
# Build documentation in the "docs/" directory with Sphinx
|
||||
sphinx:
|
||||
configuration: docs/conf.py
|
||||
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
|
||||
# builder: "dirhtml"
|
||||
# Fail on all warnings to avoid broken references
|
||||
# fail_on_warning: true
|
||||
|
||||
# Optionally build your docs in additional formats such as PDF and ePub
|
||||
# formats:
|
||||
# - pdf
|
||||
# - epub
|
||||
|
||||
# Optional but recommended, declare the Python requirements required
|
||||
# to build your documentation
|
||||
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
|
||||
# python:
|
||||
# install:
|
||||
# - requirements: docs/requirements.txt
|
||||
@ -53,4 +53,3 @@ branches:
|
||||
channel: "dev"
|
||||
prerelease: "beta"
|
||||
debug: true
|
||||
|
||||
|
||||
@ -1,13 +1,18 @@
|
||||
## [1.36.1-beta.1](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v1.36.0...v1.36.1-beta.1) (2025-01-21)
|
||||
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Schema parameter type ([2b5bd80](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/2b5bd80a945a24072e578133eacc751feeec6188))
|
||||
* search ([ce25b6a](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/ce25b6a4b0e1ea15edf14a5867f6336bb27590cb))
|
||||
|
||||
|
||||
|
||||
### Docs
|
||||
|
||||
|
||||
* add requirements.dev ([6e12981](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/6e12981e637d078a6d3b3ce83f0d4901e9dd9996))
|
||||
* added first ollama example ([aa6a76e](https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/aa6a76e5bdf63544f62786b0d17effa205aab3d8))
|
||||
|
||||
## [1.36.0](https://github.com/ScrapeGraphAI/Scrapegraph-ai/compare/v1.35.0...v1.36.0) (2025-01-12)
|
||||
|
||||
@ -6,4 +6,4 @@ RUN pip install --no-cache-dir scrapegraphai
|
||||
RUN pip install --no-cache-dir scrapegraphai[burr]
|
||||
|
||||
RUN python3 -m playwright install-deps
|
||||
RUN python3 -m playwright install
|
||||
RUN python3 -m playwright install
|
||||
|
||||
2
LICENSE
2
LICENSE
@ -4,4 +4,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@ -182,7 +182,7 @@ The Official API Documentation can be found [here](https://docs.scrapegraphai.co
|
||||
</a>
|
||||
</div>
|
||||
|
||||
## 📈 Telemetry
|
||||
## 📈 Telemetry
|
||||
We collect anonymous usage metrics to enhance our package's quality and user experience. The data helps us prioritize improvements and ensure compatibility. If you wish to opt-out, set the environment variable SCRAPEGRAPHAI_TELEMETRY_ENABLED=false. For more information, please refer to the documentation [here](https://scrapegraph-ai.readthedocs.io/en/latest/scrapers/telemetry.html).
|
||||
|
||||
|
||||
|
||||
@ -3,4 +3,3 @@
|
||||
## Reporting a Vulnerability
|
||||
|
||||
For reporting a vulnerability contact directly mvincig11@gmail.com
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ markmap:
|
||||
- Use Selenium or Playwright to take screenshots
|
||||
- Use LLM to asses if it is a block-like page, paragraph-like page, etc.
|
||||
- [Issue #88](https://github.com/VinciGit00/Scrapegraph-ai/issues/88)
|
||||
|
||||
|
||||
## **Long-Term Goals**
|
||||
|
||||
- Automatic generation of scraping pipelines from a given prompt
|
||||
|
||||
7
docs/requirements-dev.txt
Normal file
7
docs/requirements-dev.txt
Normal file
@ -0,0 +1,7 @@
|
||||
sphinx>=7.1.2
|
||||
sphinx-rtd-theme>=1.3.0
|
||||
myst-parser>=2.0.0
|
||||
sphinx-copybutton>=0.5.2
|
||||
sphinx-design>=0.5.0
|
||||
sphinx-autodoc-typehints>=1.25.2
|
||||
sphinx-autoapi>=3.0.0
|
||||
9
docs/requirements.txt
Normal file
9
docs/requirements.txt
Normal file
@ -0,0 +1,9 @@
|
||||
sphinx>=7.1.2
|
||||
|
||||
sphinx-rtd-theme>=1.3.0
|
||||
myst-parser>=2.0.0
|
||||
sphinx-copybutton>=0.5.2
|
||||
sphinx-design>=0.5.0
|
||||
sphinx-autodoc-typehints>=1.25.2
|
||||
sphinx-autoapi>=3.0.0
|
||||
furo>=2024.1.29
|
||||
@ -228,4 +228,4 @@ ScrapeGraphAI лицензирован под MIT License. Подробнее с
|
||||
## Благодарности
|
||||
|
||||
- Мы хотели бы поблагодарить всех участников проекта и сообщество с открытым исходным кодом за их поддержку.
|
||||
- ScrapeGraphAI предназначен только для исследования данных и научных целей. Мы не несем ответственности за неправильное использование библиотеки.
|
||||
- ScrapeGraphAI предназначен только для исследования данных и научных целей. Мы не несем ответственности за неправильное использование библиотеки.
|
||||
|
||||
@ -12,31 +12,30 @@ import os
|
||||
import sys
|
||||
|
||||
# import all the modules
|
||||
sys.path.insert(0, os.path.abspath('../../'))
|
||||
sys.path.insert(0, os.path.abspath("../../"))
|
||||
|
||||
project = 'ScrapeGraphAI'
|
||||
copyright = '2024, ScrapeGraphAI'
|
||||
author = 'Marco Vinciguerra, Marco Perini, Lorenzo Padoan'
|
||||
project = "ScrapeGraphAI"
|
||||
copyright = "2024, ScrapeGraphAI"
|
||||
author = "Marco Vinciguerra, Marco Perini, Lorenzo Padoan"
|
||||
|
||||
html_last_updated_fmt = "%b %d, %Y"
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
||||
|
||||
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon']
|
||||
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon"]
|
||||
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
exclude_patterns = []
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
||||
|
||||
html_theme = 'furo'
|
||||
html_theme = "furo"
|
||||
html_theme_options = {
|
||||
"source_repository": "https://github.com/VinciGit00/Scrapegraph-ai/",
|
||||
"source_branch": "main",
|
||||
"source_directory": "docs/source/",
|
||||
'navigation_with_keys': True,
|
||||
'sidebar_hide_name': False,
|
||||
"navigation_with_keys": True,
|
||||
"sidebar_hide_name": False,
|
||||
}
|
||||
|
||||
|
||||
@ -84,4 +84,4 @@ After that, you can run the following code, using only your machine resources br
|
||||
result = smart_scraper_graph.run()
|
||||
print(result)
|
||||
|
||||
To find out how you can customize the `graph_config` dictionary, by using different LLM and adding new parameters, check the `Scrapers` section!
|
||||
To find out how you can customize the `graph_config` dictionary, by using different LLM and adding new parameters, check the `Scrapers` section!
|
||||
|
||||
@ -22,7 +22,7 @@ The library is available on PyPI, so it can be installed using the following com
|
||||
pip install scrapegraphai
|
||||
|
||||
.. important::
|
||||
|
||||
|
||||
It is higly recommended to install the library in a virtual environment (conda, venv, etc.)
|
||||
|
||||
If your clone the repository, it is recommended to use a package manager like `uv <https://github.com/astral-sh/uv>`_.
|
||||
@ -35,7 +35,7 @@ To install the library using uv, you can run the following command:
|
||||
uv build
|
||||
|
||||
.. caution::
|
||||
|
||||
|
||||
**Rye** must be installed first by following the instructions on the `official website <https://github.com/astral-sh/uv>`_.
|
||||
|
||||
Additionally on Windows when using WSL
|
||||
@ -46,5 +46,3 @@ If you are using Windows Subsystem for Linux (WSL) and you are facing issues wit
|
||||
.. code-block:: bash
|
||||
|
||||
sudo apt-get -y install libnss3 libnspr4 libgbm1 libasound2
|
||||
|
||||
|
||||
|
||||
@ -43,4 +43,4 @@ Indices and tables
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
* :ref:`search`
|
||||
|
||||
@ -3,20 +3,23 @@
|
||||
:width: 50%
|
||||
:alt: ScrapegraphAI
|
||||
|
||||
Overview
|
||||
Overview
|
||||
========
|
||||
|
||||
ScrapeGraphAI is an **open-source** Python library designed to revolutionize **scraping** tools.
|
||||
In today's data-intensive digital landscape, this library stands out by integrating **Large Language Models** (LLMs)
|
||||
In today's data-intensive digital landscape, this library stands out by integrating **Large Language Models** (LLMs)
|
||||
and modular **graph-based** pipelines to automate the scraping of data from various sources (e.g., websites, local files etc.).
|
||||
|
||||
Simply specify the information you need to extract, and ScrapeGraphAI handles the rest, providing a more **flexible** and **low-maintenance** solution compared to traditional scraping tools.
|
||||
|
||||
For comprehensive documentation and updates, visit our `website <https://scrapegraphai.com>`_.
|
||||
|
||||
|
||||
Why ScrapegraphAI?
|
||||
==================
|
||||
|
||||
Traditional web scraping tools often rely on fixed patterns or manual configuration to extract data from web pages.
|
||||
ScrapegraphAI, leveraging the power of LLMs, adapts to changes in website structures, reducing the need for constant developer intervention.
|
||||
ScrapegraphAI, leveraging the power of LLMs, adapts to changes in website structures, reducing the need for constant developer intervention.
|
||||
This flexibility ensures that scrapers remain functional even when website layouts change.
|
||||
|
||||
We support many LLMs including **GPT, Gemini, Groq, Azure, Hugging Face** etc.
|
||||
@ -161,13 +164,13 @@ FAQ
|
||||
- Check your internet connection. Low speed or unstable connection can cause the HTML to not load properly.
|
||||
|
||||
- Try using a proxy server to mask your IP address. Check out the :ref:`Proxy` section for more information on how to configure proxy settings.
|
||||
|
||||
|
||||
- Use a different LLM model. Some models might perform better on certain websites than others.
|
||||
|
||||
- Set the `verbose` parameter to `True` in the graph_config to see more detailed logs.
|
||||
|
||||
- Visualize the pipeline graphically using :ref:`Burr`.
|
||||
|
||||
|
||||
If the issue persists, please report it on the GitHub repository.
|
||||
|
||||
6. **How does ScrapeGraphAI handle the context window limit of LLMs?**
|
||||
@ -200,3 +203,8 @@ Sponsors
|
||||
:width: 11%
|
||||
:alt: Scrapedo
|
||||
:target: https://scrape.do
|
||||
|
||||
.. image:: ../../assets/scrapegraph_logo.png
|
||||
:width: 11%
|
||||
:alt: ScrapegraphAI
|
||||
:target: https://scrapegraphai.com
|
||||
|
||||
@ -7,4 +7,3 @@ scrapegraphai
|
||||
scrapegraphai
|
||||
|
||||
scrapegraphai.helpers.models_tokens
|
||||
|
||||
|
||||
@ -25,4 +25,4 @@ Example usage:
|
||||
else:
|
||||
print(f"{model_name} not found in the models list")
|
||||
|
||||
This information is crucial for users to understand the capabilities and limitations of different AI models when designing their scraping pipelines.
|
||||
This information is crucial for users to understand the capabilities and limitations of different AI models when designing their scraping pipelines.
|
||||
|
||||
@ -133,11 +133,11 @@ We can also pass a model instance for the chat model and the embedding model. Fo
|
||||
openai_api_version="AZURE_OPENAI_API_VERSION",
|
||||
)
|
||||
# Supposing model_tokens are 100K
|
||||
model_tokens_count = 100000
|
||||
model_tokens_count = 100000
|
||||
graph_config = {
|
||||
"llm": {
|
||||
"model_instance": llm_model_instance,
|
||||
"model_tokens": model_tokens_count,
|
||||
"model_tokens": model_tokens_count,
|
||||
},
|
||||
"embeddings": {
|
||||
"model_instance": embedder_model_instance
|
||||
@ -198,7 +198,7 @@ We can also pass a model instance for the chat model and the embedding model. Fo
|
||||
Other LLM models
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
We can also pass a model instance for the chat model and the embedding model through the **model_instance** parameter.
|
||||
We can also pass a model instance for the chat model and the embedding model through the **model_instance** parameter.
|
||||
This feature enables you to utilize a Langchain model instance.
|
||||
You will discover the model you require within the provided list:
|
||||
|
||||
@ -208,7 +208,7 @@ You will discover the model you require within the provided list:
|
||||
For instance, consider **chat model** Moonshot. We can integrate it in the following manner:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
||||
from langchain_community.chat_models.moonshot import MoonshotChat
|
||||
|
||||
# The configuration parameters are contingent upon the specific model you select
|
||||
@ -221,8 +221,7 @@ For instance, consider **chat model** Moonshot. We can integrate it in the follo
|
||||
llm_model_instance = MoonshotChat(**llm_instance_config)
|
||||
graph_config = {
|
||||
"llm": {
|
||||
"model_instance": llm_model_instance,
|
||||
"model_instance": llm_model_instance,
|
||||
"model_tokens": 5000
|
||||
},
|
||||
}
|
||||
|
||||
@ -912,4 +912,4 @@
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,4 +11,4 @@ DEFAULT_LANGUAGE=python
|
||||
GENERATE_TESTS=true
|
||||
ADD_DOCUMENTATION=true
|
||||
CODE_STYLE=pep8
|
||||
TYPE_CHECKING=true
|
||||
TYPE_CHECKING=true
|
||||
|
||||
@ -27,4 +27,4 @@ code = graph.generate("code specification")
|
||||
## Environment Variables
|
||||
|
||||
Required environment variables:
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using Code Generator with schema
|
||||
"""
|
||||
|
||||
import json
|
||||
from typing import List
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from scrapegraphai.graphs import CodeGeneratorGraph
|
||||
|
||||
load_dotenv()
|
||||
@ -14,13 +16,16 @@ load_dotenv()
|
||||
# Define the output schema for the graph
|
||||
# ************************************************
|
||||
|
||||
|
||||
class Project(BaseModel):
|
||||
title: str = Field(description="The title of the project")
|
||||
description: str = Field(description="The description of the project")
|
||||
|
||||
|
||||
class Projects(BaseModel):
|
||||
projects: List[Project]
|
||||
|
||||
|
||||
# ************************************************
|
||||
# Define the configuration for the graph
|
||||
# ************************************************
|
||||
@ -41,9 +46,9 @@ graph_config = {
|
||||
"syntax": 3,
|
||||
"execution": 3,
|
||||
"validation": 3,
|
||||
"semantic": 3
|
||||
"semantic": 3,
|
||||
},
|
||||
"output_file_name": "extracted_data.py"
|
||||
"output_file_name": "extracted_data.py",
|
||||
}
|
||||
|
||||
# ************************************************
|
||||
@ -54,8 +59,8 @@ code_generator_graph = CodeGeneratorGraph(
|
||||
prompt="List me all the projects with their description",
|
||||
source="https://perinim.github.io/projects/",
|
||||
schema=Projects,
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = code_generator_graph.run()
|
||||
print(result)
|
||||
print(result)
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using Code Generator with schema
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import List
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from scrapegraphai.graphs import CodeGeneratorGraph
|
||||
|
||||
load_dotenv()
|
||||
@ -13,13 +16,16 @@ load_dotenv()
|
||||
# Define the output schema for the graph
|
||||
# ************************************************
|
||||
|
||||
|
||||
class Project(BaseModel):
|
||||
title: str = Field(description="The title of the project")
|
||||
description: str = Field(description="The description of the project")
|
||||
|
||||
|
||||
class Projects(BaseModel):
|
||||
projects: List[Project]
|
||||
|
||||
|
||||
# ************************************************
|
||||
# Define the configuration for the graph
|
||||
# ************************************************
|
||||
@ -28,7 +34,7 @@ openai_key = os.getenv("OPENAI_APIKEY")
|
||||
|
||||
graph_config = {
|
||||
"llm": {
|
||||
"api_key":openai_key,
|
||||
"api_key": openai_key,
|
||||
"model": "openai/gpt-4o-mini",
|
||||
},
|
||||
"verbose": True,
|
||||
@ -39,9 +45,9 @@ graph_config = {
|
||||
"syntax": 3,
|
||||
"execution": 3,
|
||||
"validation": 3,
|
||||
"semantic": 3
|
||||
"semantic": 3,
|
||||
},
|
||||
"output_file_name": "extracted_data.py"
|
||||
"output_file_name": "extracted_data.py",
|
||||
}
|
||||
|
||||
# ************************************************
|
||||
@ -52,7 +58,7 @@ code_generator_graph = CodeGeneratorGraph(
|
||||
prompt="List me all the projects with their description",
|
||||
source="https://perinim.github.io/projects/",
|
||||
schema=Projects,
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = code_generator_graph.run()
|
||||
|
||||
@ -8,4 +8,4 @@ TEMPERATURE=0.7
|
||||
|
||||
# CSV Scraper Settings
|
||||
CSV_DELIMITER=,
|
||||
MAX_ROWS=1000
|
||||
MAX_ROWS=1000
|
||||
|
||||
@ -27,4 +27,4 @@ csv_data = graph.scrape("https://example.com/table")
|
||||
## Environment Variables
|
||||
|
||||
Required environment variables:
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
|
||||
@ -4,4 +4,3 @@ grey07;2070;Laura;Grey
|
||||
johnson81;4081;Craig;Johnson
|
||||
jenkins46;9346;Mary;Jenkins
|
||||
smith79;5079;Jamie;Smith
|
||||
|
||||
|
||||
|
@ -4,4 +4,3 @@ grey07;2070;Laura;Grey
|
||||
johnson81;4081;Craig;Johnson
|
||||
jenkins46;9346;Mary;Jenkins
|
||||
smith79;5079;Jamie;Smith
|
||||
|
||||
|
||||
|
@ -10,4 +10,4 @@ TEMPERATURE=0.7
|
||||
CUSTOM_NODE_TIMEOUT=30
|
||||
MAX_NODES=10
|
||||
DEBUG_MODE=false
|
||||
LOG_LEVEL=info
|
||||
LOG_LEVEL=info
|
||||
|
||||
@ -28,4 +28,4 @@ results = graph.process()
|
||||
## Environment Variables
|
||||
|
||||
Required environment variables:
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
|
||||
@ -3,10 +3,17 @@ Example of custom graph using existing nodes
|
||||
"""
|
||||
|
||||
import os
|
||||
from langchain_openai import OpenAIEmbeddings
|
||||
from langchain_openai import ChatOpenAI
|
||||
|
||||
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
|
||||
|
||||
from scrapegraphai.graphs import BaseGraph
|
||||
from scrapegraphai.nodes import FetchNode, ParseNode, RAGNode, GenerateAnswerNode, RobotsNode
|
||||
from scrapegraphai.nodes import (
|
||||
FetchNode,
|
||||
GenerateAnswerNode,
|
||||
ParseNode,
|
||||
RAGNode,
|
||||
RobotsNode,
|
||||
)
|
||||
|
||||
# ************************************************
|
||||
# Define the configuration for the graph
|
||||
@ -20,7 +27,6 @@ graph_config = {
|
||||
# "model_tokens": 2000, # set context length arbitrarily
|
||||
"base_url": "http://localhost:11434",
|
||||
},
|
||||
|
||||
"verbose": True,
|
||||
}
|
||||
|
||||
@ -39,7 +45,7 @@ robot_node = RobotsNode(
|
||||
"llm_model": llm_model,
|
||||
"force_scraping": True,
|
||||
"verbose": True,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
fetch_node = FetchNode(
|
||||
@ -48,7 +54,7 @@ fetch_node = FetchNode(
|
||||
node_config={
|
||||
"verbose": True,
|
||||
"headless": True,
|
||||
}
|
||||
},
|
||||
)
|
||||
parse_node = ParseNode(
|
||||
input="doc",
|
||||
@ -56,7 +62,7 @@ parse_node = ParseNode(
|
||||
node_config={
|
||||
"chunk_size": 4096,
|
||||
"verbose": True,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
generate_answer_node = GenerateAnswerNode(
|
||||
@ -65,7 +71,7 @@ generate_answer_node = GenerateAnswerNode(
|
||||
node_config={
|
||||
"llm_model": llm_model,
|
||||
"verbose": True,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
# ************************************************
|
||||
@ -82,19 +88,18 @@ graph = BaseGraph(
|
||||
edges=[
|
||||
(robot_node, fetch_node),
|
||||
(fetch_node, parse_node),
|
||||
(parse_node, generate_answer_node)
|
||||
(parse_node, generate_answer_node),
|
||||
],
|
||||
entry_point=robot_node
|
||||
entry_point=robot_node,
|
||||
)
|
||||
|
||||
# ************************************************
|
||||
# Execute the graph
|
||||
# ************************************************
|
||||
|
||||
result, execution_info = graph.execute({
|
||||
"user_prompt": "Describe the content",
|
||||
"url": "https://example.com/"
|
||||
})
|
||||
result, execution_info = graph.execute(
|
||||
{"user_prompt": "Describe the content", "url": "https://example.com/"}
|
||||
)
|
||||
|
||||
# get the answer from the result
|
||||
result = result.get("answer", "No answer found.")
|
||||
|
||||
@ -1,12 +1,20 @@
|
||||
"""
|
||||
Example of custom graph using existing nodes
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from langchain_openai import OpenAIEmbeddings
|
||||
from langchain_openai import ChatOpenAI
|
||||
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
|
||||
|
||||
from scrapegraphai.graphs import BaseGraph
|
||||
from scrapegraphai.nodes import FetchNode, ParseNode, RAGNode, GenerateAnswerNode, RobotsNode
|
||||
from scrapegraphai.nodes import (
|
||||
FetchNode,
|
||||
GenerateAnswerNode,
|
||||
ParseNode,
|
||||
RAGNode,
|
||||
RobotsNode,
|
||||
)
|
||||
|
||||
load_dotenv()
|
||||
|
||||
@ -16,7 +24,7 @@ load_dotenv()
|
||||
|
||||
openai_key = os.getenv("OPENAI_APIKEY")
|
||||
graph_config = {
|
||||
"llm": {
|
||||
"llm": {
|
||||
"api_key": openai_key,
|
||||
"model": "gpt-4o",
|
||||
},
|
||||
@ -37,7 +45,7 @@ robot_node = RobotsNode(
|
||||
"llm_model": llm_model,
|
||||
"force_scraping": True,
|
||||
"verbose": True,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
fetch_node = FetchNode(
|
||||
@ -46,7 +54,7 @@ fetch_node = FetchNode(
|
||||
node_config={
|
||||
"verbose": True,
|
||||
"headless": True,
|
||||
}
|
||||
},
|
||||
)
|
||||
parse_node = ParseNode(
|
||||
input="doc",
|
||||
@ -54,7 +62,7 @@ parse_node = ParseNode(
|
||||
node_config={
|
||||
"chunk_size": 4096,
|
||||
"verbose": True,
|
||||
}
|
||||
},
|
||||
)
|
||||
rag_node = RAGNode(
|
||||
input="user_prompt & (parsed_doc | doc)",
|
||||
@ -63,7 +71,7 @@ rag_node = RAGNode(
|
||||
"llm_model": llm_model,
|
||||
"embedder_model": embedder,
|
||||
"verbose": True,
|
||||
}
|
||||
},
|
||||
)
|
||||
generate_answer_node = GenerateAnswerNode(
|
||||
input="user_prompt & (relevant_chunks | parsed_doc | doc)",
|
||||
@ -71,7 +79,7 @@ generate_answer_node = GenerateAnswerNode(
|
||||
node_config={
|
||||
"llm_model": llm_model,
|
||||
"verbose": True,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
# ************************************************
|
||||
@ -90,19 +98,18 @@ graph = BaseGraph(
|
||||
(robot_node, fetch_node),
|
||||
(fetch_node, parse_node),
|
||||
(parse_node, rag_node),
|
||||
(rag_node, generate_answer_node)
|
||||
(rag_node, generate_answer_node),
|
||||
],
|
||||
entry_point=robot_node
|
||||
entry_point=robot_node,
|
||||
)
|
||||
|
||||
# ************************************************
|
||||
# Execute the graph
|
||||
# ************************************************
|
||||
|
||||
result, execution_info = graph.execute({
|
||||
"user_prompt": "Describe the content",
|
||||
"url": "https://example.com/"
|
||||
})
|
||||
result, execution_info = graph.execute(
|
||||
{"user_prompt": "Describe the content", "url": "https://example.com/"}
|
||||
)
|
||||
|
||||
# get the answer from the result
|
||||
result = result.get("answer", "No answer found.")
|
||||
|
||||
@ -11,4 +11,4 @@ MAX_DEPTH=5
|
||||
CRAWL_DELAY=1
|
||||
RESPECT_ROBOTS_TXT=true
|
||||
MAX_PAGES_PER_DOMAIN=100
|
||||
USER_AGENT=Mozilla/5.0
|
||||
USER_AGENT=Mozilla/5.0
|
||||
|
||||
@ -27,4 +27,4 @@ results = graph.search("https://example.com", depth=3)
|
||||
## Environment Variables
|
||||
|
||||
Required environment variables:
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
"""
|
||||
depth_search_graph_opeani example
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import DepthSearchGraph
|
||||
|
||||
load_dotenv()
|
||||
@ -25,7 +28,7 @@ graph_config = {
|
||||
search_graph = DepthSearchGraph(
|
||||
prompt="List me all the projects with their description",
|
||||
source="https://perinim.github.io",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = search_graph.run()
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
"""
|
||||
depth_search_graph_opeani example
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import DepthSearchGraph
|
||||
|
||||
load_dotenv()
|
||||
@ -23,7 +26,7 @@ graph_config = {
|
||||
search_graph = DepthSearchGraph(
|
||||
prompt="List me all the projects with their description",
|
||||
source="https://perinim.github.io",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = search_graph.run()
|
||||
|
||||
@ -10,4 +10,4 @@ TEMPERATURE=0.7
|
||||
OCR_ENABLED=true
|
||||
EXTRACT_METADATA=true
|
||||
MAX_FILE_SIZE=10485760 # 10MB
|
||||
SUPPORTED_FORMATS=pdf,doc,docx,txt
|
||||
SUPPORTED_FORMATS=pdf,doc,docx,txt
|
||||
|
||||
@ -27,4 +27,4 @@ content = graph.scrape("document.pdf")
|
||||
## Environment Variables
|
||||
|
||||
Required environment variables:
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
"""
|
||||
document_scraper example
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import DocumentScraperGraph
|
||||
|
||||
load_dotenv()
|
||||
@ -22,13 +25,13 @@ graph_config = {
|
||||
}
|
||||
|
||||
source = """
|
||||
The Divine Comedy, Italian La Divina Commedia, original name La commedia, long narrative poem written in Italian
|
||||
circa 1308/21 by Dante. It is usually held to be one of the world s great works of literature.
|
||||
Divided into three major sections—Inferno, Purgatorio, and Paradiso—the narrative traces the journey of Dante
|
||||
from darkness and error to the revelation of the divine light, culminating in the Beatific Vision of God.
|
||||
Dante is guided by the Roman poet Virgil, who represents the epitome of human knowledge, from the dark wood
|
||||
through the descending circles of the pit of Hell (Inferno). He then climbs the mountain of Purgatory, guided
|
||||
by the Roman poet Statius, who represents the fulfilment of human knowledge, and is finally led by his lifelong love,
|
||||
The Divine Comedy, Italian La Divina Commedia, original name La commedia, long narrative poem written in Italian
|
||||
circa 1308/21 by Dante. It is usually held to be one of the world s great works of literature.
|
||||
Divided into three major sections—Inferno, Purgatorio, and Paradiso—the narrative traces the journey of Dante
|
||||
from darkness and error to the revelation of the divine light, culminating in the Beatific Vision of God.
|
||||
Dante is guided by the Roman poet Virgil, who represents the epitome of human knowledge, from the dark wood
|
||||
through the descending circles of the pit of Hell (Inferno). He then climbs the mountain of Purgatory, guided
|
||||
by the Roman poet Statius, who represents the fulfilment of human knowledge, and is finally led by his lifelong love,
|
||||
the Beatrice of his earlier poetry, through the celestial spheres of Paradise.
|
||||
"""
|
||||
|
||||
|
||||
@ -2,16 +2,16 @@
|
||||
<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 </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>
|
||||
<a class="navbar-brand title font-weight-lighter" href="/"><span class="font-weight-bold">Marco </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>
|
||||
<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>
|
||||
<a class="dropdown-item" href="/projects/">Projects</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="/competitions/">Competitions</a>
|
||||
<a class="dropdown-item" href="/competitions/">Competitions</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="nav-item "> <a class="nav-link" href="/cv/">CV</a> </li>
|
||||
@ -100,6 +100,6 @@
|
||||
</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>
|
||||
</footer>
|
||||
<div class="hiddendiv common"></div>
|
||||
</body>
|
||||
</body>
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
"""
|
||||
document_scraper example
|
||||
"""
|
||||
import os
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import DocumentScraperGraph
|
||||
|
||||
load_dotenv()
|
||||
@ -19,13 +22,13 @@ graph_config = {
|
||||
}
|
||||
|
||||
source = """
|
||||
The Divine Comedy, Italian La Divina Commedia, original name La commedia, long narrative poem written in Italian
|
||||
circa 1308/21 by Dante. It is usually held to be one of the world s great works of literature.
|
||||
Divided into three major sections—Inferno, Purgatorio, and Paradiso—the narrative traces the journey of Dante
|
||||
from darkness and error to the revelation of the divine light, culminating in the Beatific Vision of God.
|
||||
Dante is guided by the Roman poet Virgil, who represents the epitome of human knowledge, from the dark wood
|
||||
through the descending circles of the pit of Hell (Inferno). He then climbs the mountain of Purgatory, guided
|
||||
by the Roman poet Statius, who represents the fulfilment of human knowledge, and is finally led by his lifelong love,
|
||||
The Divine Comedy, Italian La Divina Commedia, original name La commedia, long narrative poem written in Italian
|
||||
circa 1308/21 by Dante. It is usually held to be one of the world s great works of literature.
|
||||
Divided into three major sections—Inferno, Purgatorio, and Paradiso—the narrative traces the journey of Dante
|
||||
from darkness and error to the revelation of the divine light, culminating in the Beatific Vision of God.
|
||||
Dante is guided by the Roman poet Virgil, who represents the epitome of human knowledge, from the dark wood
|
||||
through the descending circles of the pit of Hell (Inferno). He then climbs the mountain of Purgatory, guided
|
||||
by the Roman poet Statius, who represents the fulfilment of human knowledge, and is finally led by his lifelong love,
|
||||
the Beatrice of his earlier poetry, through the celestial spheres of Paradise.
|
||||
"""
|
||||
|
||||
@ -36,4 +39,4 @@ pdf_scraper_graph = DocumentScraperGraph(
|
||||
)
|
||||
result = pdf_scraper_graph.run()
|
||||
|
||||
print(json.dumps(result, indent=4))
|
||||
print(json.dumps(result, indent=4))
|
||||
|
||||
@ -1,35 +1,35 @@
|
||||
Marco Perini Toggle navigation
|
||||
|
||||
* About
|
||||
* Projects(current)
|
||||
|
||||
Projects
|
||||
|
||||
Competitions
|
||||
|
||||
* CV
|
||||
* ____
|
||||
|
||||
# Projects
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
© Copyright 2023 Marco Perini. Powered by Jekyll with
|
||||
al-folio theme. Hosted by [GitHub
|
||||
Pages](https://pages.github.com/).
|
||||
Marco Perini Toggle navigation
|
||||
|
||||
* About
|
||||
* Projects(current)
|
||||
|
||||
Projects
|
||||
|
||||
Competitions
|
||||
|
||||
* CV
|
||||
* ____
|
||||
|
||||
# Projects
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
© Copyright 2023 Marco Perini. Powered by Jekyll with
|
||||
al-folio theme. Hosted by [GitHub
|
||||
Pages](https://pages.github.com/).
|
||||
|
||||
@ -2,16 +2,16 @@
|
||||
<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 </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>
|
||||
<a class="navbar-brand title font-weight-lighter" href="/"><span class="font-weight-bold">Marco </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>
|
||||
<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>
|
||||
<a class="dropdown-item" href="/projects/">Projects</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="/competitions/">Competitions</a>
|
||||
<a class="dropdown-item" href="/competitions/">Competitions</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="nav-item "> <a class="nav-link" href="/cv/">CV</a> </li>
|
||||
@ -100,6 +100,6 @@
|
||||
</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>
|
||||
</footer>
|
||||
<div class="hiddendiv common"></div>
|
||||
</body>
|
||||
</body>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
|
||||
BROWSER_BASE_PROJECT_ID="YOUR_BROWSER_BASE_PROJECT_ID"
|
||||
BROWSER_BASE_API_KEY="YOUR_BROWSERBASE_API_KEY"
|
||||
SCRAPE_DO_API_KEY="YOUR_SCRAPE_DO_API_KEY"
|
||||
SCRAPE_DO_API_KEY="YOUR_SCRAPE_DO_API_KEY"
|
||||
|
||||
@ -6,6 +6,7 @@ content.
|
||||
|
||||
import os
|
||||
import random
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# import playwright so we can use it to create the state file
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using SmartScraper
|
||||
"""
|
||||
|
||||
import os
|
||||
import json
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import SmartScraperGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
@ -35,7 +37,7 @@ graph_config = {
|
||||
smart_scraper_graph = SmartScraperGraph(
|
||||
prompt="List me what does the company do, the name and a contact email.",
|
||||
source="https://scrapegraphai.com/",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = smart_scraper_graph.run()
|
||||
|
||||
@ -1,22 +1,27 @@
|
||||
import asyncio
|
||||
import os
|
||||
import json
|
||||
import os
|
||||
|
||||
from aiohttp import ClientError
|
||||
from dotenv import load_dotenv
|
||||
from scrapegraphai.docloaders.chromium import ChromiumLoader # Import your ChromiumLoader class
|
||||
|
||||
from scrapegraphai.docloaders.chromium import ( # Import your ChromiumLoader class
|
||||
ChromiumLoader,
|
||||
)
|
||||
from scrapegraphai.graphs import SmartScraperGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
from aiohttp import ClientError
|
||||
|
||||
# Load environment variables for API keys
|
||||
load_dotenv()
|
||||
|
||||
|
||||
# ************************************************
|
||||
# Define function to analyze content with ScrapegraphAI
|
||||
# ************************************************
|
||||
async def analyze_content_with_scrapegraph(content: str):
|
||||
"""
|
||||
Analyze scraped content using ScrapegraphAI.
|
||||
|
||||
|
||||
Args:
|
||||
content (str): The scraped HTML or text content.
|
||||
|
||||
@ -33,8 +38,8 @@ async def analyze_content_with_scrapegraph(content: str):
|
||||
"api_key": os.getenv("OPENAI_API_KEY"),
|
||||
"model": "openai/gpt-4o",
|
||||
},
|
||||
"verbose": True
|
||||
}
|
||||
"verbose": True,
|
||||
},
|
||||
)
|
||||
result = smart_scraper.run()
|
||||
return result
|
||||
@ -42,6 +47,7 @@ async def analyze_content_with_scrapegraph(content: str):
|
||||
print(f"❌ ScrapegraphAI analysis failed: {e}")
|
||||
return {"error": str(e)}
|
||||
|
||||
|
||||
# ************************************************
|
||||
# Test scraper and ScrapegraphAI pipeline
|
||||
# ************************************************
|
||||
@ -61,7 +67,9 @@ async def test_scraper_with_analysis(scraper: ChromiumLoader, urls: list):
|
||||
if "Error" in result or not result.strip():
|
||||
print(f"❌ Failed to scrape {url}: {result}")
|
||||
else:
|
||||
print(f"✅ Successfully scraped {url}. Content (first 200 chars): {result[:200]}")
|
||||
print(
|
||||
f"✅ Successfully scraped {url}. Content (first 200 chars): {result[:200]}"
|
||||
)
|
||||
|
||||
# Pass scraped content to ScrapegraphAI for analysis
|
||||
print("🤖 Analyzing content with ScrapegraphAI...")
|
||||
@ -74,6 +82,7 @@ async def test_scraper_with_analysis(scraper: ChromiumLoader, urls: list):
|
||||
except Exception as e:
|
||||
print(f"❌ Unexpected error while scraping {url}: {e}")
|
||||
|
||||
|
||||
# ************************************************
|
||||
# Main Execution
|
||||
# ************************************************
|
||||
@ -81,16 +90,26 @@ async def main():
|
||||
urls_to_scrape = [
|
||||
"https://example.com",
|
||||
"https://www.python.org",
|
||||
"https://invalid-url.test"
|
||||
"https://invalid-url.test",
|
||||
]
|
||||
|
||||
# Test with Playwright backend
|
||||
print("\n--- Testing Playwright Backend ---")
|
||||
try:
|
||||
scraper_playwright_chromium = ChromiumLoader(urls=urls_to_scrape, backend="playwright", headless=True, browser_name = "chromium")
|
||||
scraper_playwright_chromium = ChromiumLoader(
|
||||
urls=urls_to_scrape,
|
||||
backend="playwright",
|
||||
headless=True,
|
||||
browser_name="chromium",
|
||||
)
|
||||
await test_scraper_with_analysis(scraper_playwright_chromium, urls_to_scrape)
|
||||
|
||||
scraper_playwright_firefox = ChromiumLoader(urls=urls_to_scrape, backend="playwright", headless=True, browser_name = "firefox")
|
||||
|
||||
scraper_playwright_firefox = ChromiumLoader(
|
||||
urls=urls_to_scrape,
|
||||
backend="playwright",
|
||||
headless=True,
|
||||
browser_name="firefox",
|
||||
)
|
||||
await test_scraper_with_analysis(scraper_playwright_firefox, urls_to_scrape)
|
||||
except ImportError as ie:
|
||||
print(f"❌ Playwright ImportError: {ie}")
|
||||
@ -100,16 +119,27 @@ async def main():
|
||||
# Test with Selenium backend
|
||||
print("\n--- Testing Selenium Backend ---")
|
||||
try:
|
||||
scraper_selenium_chromium = ChromiumLoader(urls=urls_to_scrape, backend="selenium", headless=True, browser_name = "chromium")
|
||||
scraper_selenium_chromium = ChromiumLoader(
|
||||
urls=urls_to_scrape,
|
||||
backend="selenium",
|
||||
headless=True,
|
||||
browser_name="chromium",
|
||||
)
|
||||
await test_scraper_with_analysis(scraper_selenium_chromium, urls_to_scrape)
|
||||
|
||||
scraper_selenium_firefox = ChromiumLoader(urls=urls_to_scrape, backend="selenium", headless=True, browser_name = "firefox")
|
||||
|
||||
scraper_selenium_firefox = ChromiumLoader(
|
||||
urls=urls_to_scrape,
|
||||
backend="selenium",
|
||||
headless=True,
|
||||
browser_name="firefox",
|
||||
)
|
||||
await test_scraper_with_analysis(scraper_selenium_firefox, urls_to_scrape)
|
||||
except ImportError as ie:
|
||||
print(f"❌ Selenium ImportError: {ie}")
|
||||
except Exception as e:
|
||||
print(f"❌ Error initializing Selenium ChromiumLoader: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
asyncio.run(main())
|
||||
|
||||
@ -2,9 +2,11 @@
|
||||
Basic example of scraping pipeline using SmartScraperMultiConcatGraph with Groq
|
||||
"""
|
||||
|
||||
import os
|
||||
import json
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import SmartScraperGraph
|
||||
|
||||
load_dotenv()
|
||||
@ -20,7 +22,7 @@ graph_config = {
|
||||
},
|
||||
"verbose": True,
|
||||
"headless": True,
|
||||
"reattempt": True #Setting this to True will allow the graph to reattempt the scraping process
|
||||
"reattempt": True, # Setting this to True will allow the graph to reattempt the scraping process
|
||||
}
|
||||
|
||||
# *******************************************************
|
||||
@ -31,7 +33,7 @@ multiple_search_graph = SmartScraperGraph(
|
||||
prompt="Who is Marco Perini?",
|
||||
source="https://perinim.github.io/",
|
||||
schema=None,
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = multiple_search_graph.run()
|
||||
|
||||
@ -2,9 +2,11 @@
|
||||
Basic example of scraping pipeline using SmartScraperMultiConcatGraph with Groq
|
||||
"""
|
||||
|
||||
import os
|
||||
import json
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import SmartScraperMultiGraph
|
||||
|
||||
load_dotenv()
|
||||
@ -18,7 +20,6 @@ graph_config = {
|
||||
"api_key": os.getenv("OPENAI_API_KEY"),
|
||||
"model": "openai/gpt-4o",
|
||||
},
|
||||
|
||||
"verbose": True,
|
||||
"headless": False,
|
||||
}
|
||||
@ -29,12 +30,9 @@ graph_config = {
|
||||
|
||||
multiple_search_graph = SmartScraperMultiGraph(
|
||||
prompt="Who is Marco Perini?",
|
||||
source=[
|
||||
"https://perinim.github.io/",
|
||||
"https://perinim.github.io/cv/"
|
||||
],
|
||||
source=["https://perinim.github.io/", "https://perinim.github.io/cv/"],
|
||||
schema=None,
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = multiple_search_graph.run()
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using SmartScraper
|
||||
"""
|
||||
import os
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import SmartScraperGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
|
||||
@ -3,13 +3,13 @@
|
||||
"model": "ollama/llama3",
|
||||
"temperature": 0,
|
||||
"format": "json",
|
||||
# "base_url": "http://localhost:11434",
|
||||
# "base_url": "http://localhost:11434",
|
||||
},
|
||||
"embeddings": {
|
||||
"model": "ollama/nomic-embed-text",
|
||||
"temperature": 0,
|
||||
# "base_url": "http://localhost:11434",
|
||||
# "base_url": "http://localhost:11434",
|
||||
},
|
||||
"verbose": true,
|
||||
"headless": false
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using SmartScraper
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import SmartScraperGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
@ -17,7 +19,7 @@ load_dotenv()
|
||||
openai_key = os.getenv("OPENAI_APIKEY")
|
||||
|
||||
graph_config = {
|
||||
"llm": {
|
||||
"llm": {
|
||||
"model": "ollama/llama3",
|
||||
"temperature": 0,
|
||||
# "format": "json", # Ollama needs the format to be specified explicitly
|
||||
@ -29,7 +31,7 @@ graph_config = {
|
||||
# "base_url": "http://localhost:11434", # set ollama URL arbitrarily
|
||||
},
|
||||
"force": True,
|
||||
"caching": True
|
||||
"caching": True,
|
||||
}
|
||||
|
||||
# ************************************************
|
||||
@ -40,7 +42,7 @@ smart_scraper_graph = SmartScraperGraph(
|
||||
prompt="List me all the projects with their description.",
|
||||
# also accepts a string with the already downloaded HTML code
|
||||
source="https://perinim.github.io/projects/",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = smart_scraper_graph.run()
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using SmartScraper
|
||||
By default smart scraper converts in md format the
|
||||
By default smart scraper converts in md format the
|
||||
code. If you want to just use the original code, you have
|
||||
to specify in the confi
|
||||
"""
|
||||
|
||||
import os
|
||||
import json
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import SmartScraperGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
@ -35,7 +37,7 @@ graph_config = {
|
||||
smart_scraper_graph = SmartScraperGraph(
|
||||
prompt="List me what does the company do, the name and a contact email.",
|
||||
source="https://scrapegraphai.com/",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = smart_scraper_graph.run()
|
||||
|
||||
@ -1,14 +1,16 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using SmartScraper
|
||||
"""
|
||||
|
||||
import yaml
|
||||
|
||||
from scrapegraphai.graphs import SmartScraperGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
# ************************************************
|
||||
# Define the configuration for the graph
|
||||
# ************************************************
|
||||
with open("example.yml", 'r') as file:
|
||||
with open("example.yml", "r") as file:
|
||||
graph_config = yaml.safe_load(file)
|
||||
|
||||
# ************************************************
|
||||
@ -18,7 +20,7 @@ with open("example.yml", 'r') as file:
|
||||
smart_scraper_graph = SmartScraperGraph(
|
||||
prompt="List me all the titles",
|
||||
source="https://sport.sky.it/nba?gr=www",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = smart_scraper_graph.run()
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
"""
|
||||
"""
|
||||
This example shows how to do not process the html code in the fetch phase
|
||||
"""
|
||||
|
||||
import os, json
|
||||
import json
|
||||
import os
|
||||
|
||||
from scrapegraphai.graphs import SmartScraperGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
|
||||
# ************************************************
|
||||
# Define the configuration for the graph
|
||||
# ************************************************
|
||||
@ -29,7 +30,7 @@ graph_config = {
|
||||
smart_scraper_graph = SmartScraperGraph(
|
||||
prompt="Extract me the python code inside the page",
|
||||
source="https://www.exploit-db.com/exploits/51447",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = smart_scraper_graph.run()
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using SmartScraper
|
||||
"""
|
||||
|
||||
from scrapegraphai.graphs import SmartScraperGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
|
||||
# ************************************************
|
||||
# Define the configuration for the graph
|
||||
# ************************************************
|
||||
@ -16,12 +15,12 @@ graph_config = {
|
||||
"model": "openai/gpt-3.5-turbo",
|
||||
},
|
||||
"loader_kwargs": {
|
||||
"proxy" : {
|
||||
"proxy": {
|
||||
"server": "http:/**********",
|
||||
"username": "********",
|
||||
"password": "***",
|
||||
},
|
||||
},
|
||||
},
|
||||
"verbose": True,
|
||||
"headless": False,
|
||||
}
|
||||
@ -34,7 +33,7 @@ smart_scraper_graph = SmartScraperGraph(
|
||||
prompt="List me all the projects with their description",
|
||||
# also accepts a string with the already downloaded HTML code
|
||||
source="https://perinim.github.io/projects/",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = smart_scraper_graph.run()
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using SmartScraper
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import SmartScraperGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
@ -21,7 +23,7 @@ graph_config = {
|
||||
"api_key": openai_key,
|
||||
"model": "openai/gpt-3.5-turbo",
|
||||
},
|
||||
"caching": True
|
||||
"caching": True,
|
||||
}
|
||||
|
||||
# ************************************************
|
||||
@ -32,7 +34,7 @@ smart_scraper_graph = SmartScraperGraph(
|
||||
prompt="List me all the projects with their description.",
|
||||
# also accepts a string with the already downloaded HTML code
|
||||
source="https://perinim.github.io/projects/",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = smart_scraper_graph.run()
|
||||
@ -43,4 +45,4 @@ print(result)
|
||||
# ************************************************
|
||||
|
||||
graph_exec_info = smart_scraper_graph.get_execution_info()
|
||||
print(prettify_exec_info(graph_exec_info))
|
||||
print(prettify_exec_info(graph_exec_info))
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using SmartScraper
|
||||
"""
|
||||
|
||||
import os
|
||||
import json
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import SmartScraperGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
@ -32,7 +34,7 @@ graph_config = {
|
||||
smart_scraper_graph = SmartScraperGraph(
|
||||
prompt="List me what does the company do, the name and a contact email.",
|
||||
source="https://scrapegraphai.com/",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = smart_scraper_graph.run()
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using SmartScraper
|
||||
"""
|
||||
|
||||
import os
|
||||
import json
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import SmartScraperGraph
|
||||
|
||||
load_dotenv()
|
||||
@ -33,7 +35,7 @@ graph_config = {
|
||||
smart_scraper_graph = SmartScraperGraph(
|
||||
prompt="List me all the projects",
|
||||
source="https://perinim.github.io/projects/",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = smart_scraper_graph.run()
|
||||
|
||||
@ -1,31 +1,38 @@
|
||||
"""
|
||||
example of scraping with screenshots
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from scrapegraphai.utils.screenshot_scraping import (take_screenshot,
|
||||
select_area_with_opencv,
|
||||
crop_image, detect_text)
|
||||
|
||||
from scrapegraphai.utils.screenshot_scraping import (
|
||||
crop_image,
|
||||
detect_text,
|
||||
select_area_with_opencv,
|
||||
take_screenshot,
|
||||
)
|
||||
|
||||
# STEP 1: Take a screenshot
|
||||
image = asyncio.run(take_screenshot(
|
||||
url="https://colab.google/",
|
||||
save_path="Savedscreenshots/test_image.jpeg",
|
||||
quality = 50
|
||||
))
|
||||
image = asyncio.run(
|
||||
take_screenshot(
|
||||
url="https://colab.google/",
|
||||
save_path="Savedscreenshots/test_image.jpeg",
|
||||
quality=50,
|
||||
)
|
||||
)
|
||||
|
||||
# STEP 2 (Optional): Select an area of the image which you want to use for text detection.
|
||||
LEFT, TOP, RIGHT, BOTTOM = select_area_with_opencv(image)
|
||||
print("LEFT: ", LEFT, " TOP: ", TOP, " RIGHT: ", RIGHT, " BOTTOM: ", BOTTOM)
|
||||
|
||||
# STEP 3 (Optional): Crop the image.
|
||||
# Note: If any of the coordinates (LEFT, TOP, RIGHT, BOTTOM) is None,
|
||||
# Note: If any of the coordinates (LEFT, TOP, RIGHT, BOTTOM) is None,
|
||||
# it will be set to the corresponding edge of the image.
|
||||
cropped_image = crop_image(image, LEFT=LEFT, RIGHT=RIGHT,TOP=TOP,BOTTOM=BOTTOM)
|
||||
cropped_image = crop_image(image, LEFT=LEFT, RIGHT=RIGHT, TOP=TOP, BOTTOM=BOTTOM)
|
||||
|
||||
# STEP 4: Detect text
|
||||
TEXT = detect_text(
|
||||
cropped_image, # The image to detect text from
|
||||
languages = ["en"] # The languages to detect text in
|
||||
cropped_image, # The image to detect text from
|
||||
languages=["en"], # The languages to detect text in
|
||||
)
|
||||
|
||||
print("DETECTED TEXT: ")
|
||||
|
||||
@ -3,28 +3,34 @@ Example of Search Graph
|
||||
"""
|
||||
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
from scrapegraphai.graphs import SearchGraph
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import List
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from scrapegraphai.graphs import SearchGraph
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
||||
# ************************************************
|
||||
# Define the configuration for the graph
|
||||
# ************************************************
|
||||
class CeoName(BaseModel):
|
||||
ceo_name: str = Field(description="The name and surname of the ceo")
|
||||
|
||||
|
||||
class Ceos(BaseModel):
|
||||
names: List[CeoName]
|
||||
|
||||
|
||||
openai_key = os.getenv("OPENAI_APIKEY")
|
||||
|
||||
graph_config = {
|
||||
"llm": {
|
||||
"api_key": openai_key,
|
||||
"model": "openai/gpt-4o",
|
||||
},
|
||||
},
|
||||
"max_results": 2,
|
||||
"verbose": True,
|
||||
}
|
||||
@ -35,7 +41,7 @@ graph_config = {
|
||||
|
||||
search_graph = SearchGraph(
|
||||
prompt=f"Who is the ceo of Appke?",
|
||||
schema = Ceos,
|
||||
schema=Ceos,
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using SmartScraper
|
||||
"""
|
||||
|
||||
from scrapegraphai.graphs import SmartScraperGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
# ************************************************
|
||||
# Define the configuration for the graph
|
||||
# ************************************************
|
||||
@ -19,11 +21,9 @@ graph_config = {
|
||||
"temperature": 0,
|
||||
# "base_url": "http://localhost:11434", # set ollama URL arbitrarily
|
||||
},
|
||||
"loader_kwargs": {
|
||||
"slow_mo": 10000
|
||||
},
|
||||
"loader_kwargs": {"slow_mo": 10000},
|
||||
"verbose": True,
|
||||
"headless": False
|
||||
"headless": False,
|
||||
}
|
||||
|
||||
# ************************************************
|
||||
@ -34,7 +34,7 @@ smart_scraper_graph = SmartScraperGraph(
|
||||
prompt="List me all the titles",
|
||||
# also accepts a string with the already downloaded HTML code
|
||||
source="https://www.wired.com/",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = smart_scraper_graph.run()
|
||||
@ -45,4 +45,4 @@ print(result)
|
||||
# ************************************************
|
||||
|
||||
graph_exec_info = smart_scraper_graph.get_execution_info()
|
||||
print(prettify_exec_info(graph_exec_info))
|
||||
print(prettify_exec_info(graph_exec_info))
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using SmartScraper
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import SmartScraperGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
@ -16,13 +18,9 @@ load_dotenv()
|
||||
groq_key = os.getenv("GROQ_APIKEY")
|
||||
|
||||
graph_config = {
|
||||
"llm": {
|
||||
"model": "groq/gemma-7b-it",
|
||||
"api_key": groq_key,
|
||||
"temperature": 0
|
||||
},
|
||||
"llm": {"model": "groq/gemma-7b-it", "api_key": groq_key, "temperature": 0},
|
||||
"headless": False,
|
||||
"backend": "undetected_chromedriver"
|
||||
"backend": "undetected_chromedriver",
|
||||
}
|
||||
|
||||
# ************************************************
|
||||
@ -33,7 +31,7 @@ smart_scraper_graph = SmartScraperGraph(
|
||||
prompt="List me all the projects with their description.",
|
||||
# also accepts a string with the already downloaded HTML code
|
||||
source="https://perinim.github.io/projects/",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = smart_scraper_graph.run()
|
||||
|
||||
@ -8,4 +8,4 @@ TEMPERATURE=0.7
|
||||
|
||||
# JSON Scraper Settings
|
||||
MAX_DEPTH=3
|
||||
TIMEOUT=30
|
||||
TIMEOUT=30
|
||||
|
||||
@ -27,4 +27,4 @@ json_data = graph.scrape("https://api.example.com/data")
|
||||
## Environment Variables
|
||||
|
||||
Required environment variables:
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
|
||||
@ -179,4 +179,4 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
"""
|
||||
Module for showing how PDFScraper multi works
|
||||
"""
|
||||
import os
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from scrapegraphai.graphs import JSONScraperMultiGraph
|
||||
|
||||
graph_config = {
|
||||
@ -20,16 +22,16 @@ FILE_NAME = "inputs/example.json"
|
||||
curr_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
file_path = os.path.join(curr_dir, FILE_NAME)
|
||||
|
||||
with open(file_path, 'r', encoding="utf-8") as file:
|
||||
with open(file_path, "r", encoding="utf-8") as file:
|
||||
text = file.read()
|
||||
|
||||
sources = [text, text]
|
||||
|
||||
multiple_search_graph = JSONScraperMultiGraph(
|
||||
prompt= "List me all the authors, title and genres of the books",
|
||||
source= sources,
|
||||
prompt="List me all the authors, title and genres of the books",
|
||||
source=sources,
|
||||
schema=None,
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = multiple_search_graph.run()
|
||||
|
||||
@ -3,9 +3,12 @@ Basic example of scraping pipeline using JSONScraperGraph from JSON documents
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import JSONScraperGraph
|
||||
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# ************************************************
|
||||
@ -16,7 +19,7 @@ FILE_NAME = "inputs/example.json"
|
||||
curr_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
file_path = os.path.join(curr_dir, FILE_NAME)
|
||||
|
||||
with open(file_path, 'r', encoding="utf-8") as file:
|
||||
with open(file_path, "r", encoding="utf-8") as file:
|
||||
text = file.read()
|
||||
|
||||
# ************************************************
|
||||
@ -41,7 +44,7 @@ graph_config = {
|
||||
json_scraper_graph = JSONScraperGraph(
|
||||
prompt="List me all the authors, title and genres of the books",
|
||||
source=text, # Pass the content of the file, not the file object
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = json_scraper_graph.run()
|
||||
|
||||
@ -179,4 +179,4 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
"""
|
||||
Module for showing how PDFScraper multi works
|
||||
"""
|
||||
import os
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import JSONScraperMultiGraph
|
||||
|
||||
load_dotenv()
|
||||
@ -21,16 +24,16 @@ FILE_NAME = "inputs/example.json"
|
||||
curr_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
file_path = os.path.join(curr_dir, FILE_NAME)
|
||||
|
||||
with open(file_path, 'r', encoding="utf-8") as file:
|
||||
with open(file_path, "r", encoding="utf-8") as file:
|
||||
text = file.read()
|
||||
|
||||
sources = [text, text]
|
||||
|
||||
multiple_search_graph = JSONScraperMultiGraph(
|
||||
prompt= "List me all the authors, title and genres of the books",
|
||||
source= sources,
|
||||
prompt="List me all the authors, title and genres of the books",
|
||||
source=sources,
|
||||
schema=None,
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = multiple_search_graph.run()
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
"""
|
||||
Basic example of scraping pipeline using JSONScraperGraph from JSON documents
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import JSONScraperGraph
|
||||
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
|
||||
|
||||
@ -16,7 +19,7 @@ FILE_NAME = "inputs/example.json"
|
||||
curr_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
file_path = os.path.join(curr_dir, FILE_NAME)
|
||||
|
||||
with open(file_path, 'r', encoding="utf-8") as file:
|
||||
with open(file_path, "r", encoding="utf-8") as file:
|
||||
text = file.read()
|
||||
|
||||
# ************************************************
|
||||
@ -39,7 +42,7 @@ graph_config = {
|
||||
json_scraper_graph = JSONScraperGraph(
|
||||
prompt="List me all the authors, title and genres of the books",
|
||||
source=text, # Pass the content of the file, not the file object
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = json_scraper_graph.run()
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
"""
|
||||
Basic example of scraping pipeline using DocumentScraperGraph from MD documents
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import DocumentScraperGraph
|
||||
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
|
||||
|
||||
@ -16,7 +19,7 @@ FILE_NAME = "inputs/markdown_example.md"
|
||||
curr_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
file_path = os.path.join(curr_dir, FILE_NAME)
|
||||
|
||||
with open(file_path, 'r', encoding="utf-8") as file:
|
||||
with open(file_path, "r", encoding="utf-8") as file:
|
||||
text = file.read()
|
||||
|
||||
# ************************************************
|
||||
@ -39,7 +42,7 @@ graph_config = {
|
||||
md_scraper_graph = DocumentScraperGraph(
|
||||
prompt="List me all the projects",
|
||||
source=text, # Pass the content of the file, not the file object
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = md_scraper_graph.run()
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using OmniScraper
|
||||
"""
|
||||
import os
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import OmniScraperGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
@ -22,7 +25,7 @@ graph_config = {
|
||||
},
|
||||
"verbose": True,
|
||||
"headless": True,
|
||||
"max_images": 5
|
||||
"max_images": 5,
|
||||
}
|
||||
|
||||
# ************************************************
|
||||
@ -33,7 +36,7 @@ omni_scraper_graph = OmniScraperGraph(
|
||||
prompt="List me all the projects with their titles and image links and descriptions.",
|
||||
# also accepts a string with the already downloaded HTML code
|
||||
source="https://perinim.github.io/projects/",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = omni_scraper_graph.run()
|
||||
|
||||
@ -10,4 +10,4 @@ TEMPERATURE=0.7
|
||||
DEFAULT_FORMAT=auto
|
||||
TIMEOUT=60
|
||||
MAX_RETRIES=3
|
||||
USER_AGENT=Mozilla/5.0
|
||||
USER_AGENT=Mozilla/5.0
|
||||
|
||||
@ -27,4 +27,4 @@ data = graph.scrape("https://example.com/data")
|
||||
## Environment Variables
|
||||
|
||||
Required environment variables:
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
"""
|
||||
Example of OmniSearchGraph
|
||||
"""
|
||||
import os
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import OmniSearchGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
@ -31,7 +34,7 @@ graph_config = {
|
||||
|
||||
omni_search_graph = OmniSearchGraph(
|
||||
prompt="List me all Chioggia's famous dishes and describe their pictures.",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = omni_search_graph.run()
|
||||
|
||||
@ -19,7 +19,7 @@ This directory contains various example implementations of Scrapegraph-ai for di
|
||||
- 🛠️ `custom_graph/` - Custom graph implementation examples
|
||||
- 💻 `code_generator_graph/` - Code generation utilities
|
||||
- 📋 `json_scraper_graph/` - JSON data extraction and processing
|
||||
- 📋 `colab example`:
|
||||
- 📋 `colab example`:
|
||||
<a target="_blank" href="https://colab.research.google.com/drive/1sEZBonBMGP44CtO6GQTwAlL0BGJXjtfd?usp=sharing#scrollTo=vGDjka17pqqg">
|
||||
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
|
||||
</a>
|
||||
|
||||
@ -10,4 +10,4 @@ TEMPERATURE=0.7
|
||||
DEFAULT_LANGUAGE=python
|
||||
INCLUDE_COMMENTS=true
|
||||
ADD_TYPE_HINTS=true
|
||||
CODE_STYLE=pep8
|
||||
CODE_STYLE=pep8
|
||||
|
||||
@ -27,4 +27,4 @@ script = graph.generate("task description")
|
||||
## Environment Variables
|
||||
|
||||
Required environment variables:
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
"""
|
||||
Basic example of scraping pipeline using ScriptCreatorGraph
|
||||
"""
|
||||
|
||||
from scrapegraphai.graphs import ScriptCreatorGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
# ************************************************
|
||||
# Define the configuration for the graph
|
||||
# ************************************************
|
||||
@ -26,7 +28,7 @@ smart_scraper_graph = ScriptCreatorGraph(
|
||||
prompt="List me all the news with their description.",
|
||||
# also accepts a string with the already downloaded HTML code
|
||||
source="https://perinim.github.io/projects",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = smart_scraper_graph.run()
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using ScriptCreatorGraph
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import ScriptCreatorMultiGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
@ -28,7 +30,7 @@ graph_config = {
|
||||
# Create the ScriptCreatorGraph instance and run it
|
||||
# ************************************************
|
||||
|
||||
urls=[
|
||||
urls = [
|
||||
"https://schultzbergagency.com/emil-raste-karlsen/",
|
||||
"https://schultzbergagency.com/johanna-hedberg/",
|
||||
]
|
||||
@ -41,7 +43,7 @@ script_creator_graph = ScriptCreatorMultiGraph(
|
||||
prompt="Find information about actors",
|
||||
# also accepts a string with the already downloaded HTML code
|
||||
source=urls,
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = script_creator_graph.run()
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using ScriptCreatorGraph
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import ScriptCreatorMultiGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
@ -27,7 +30,7 @@ graph_config = {
|
||||
# Create the ScriptCreatorGraph instance and run it
|
||||
# ************************************************
|
||||
|
||||
urls=[
|
||||
urls = [
|
||||
"https://schultzbergagency.com/emil-raste-karlsen/",
|
||||
"https://schultzbergagency.com/johanna-hedberg/",
|
||||
]
|
||||
@ -40,7 +43,7 @@ script_creator_graph = ScriptCreatorMultiGraph(
|
||||
prompt="Find information about actors",
|
||||
# also accepts a string with the already downloaded HTML code
|
||||
source=urls,
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = script_creator_graph.run()
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using SmartScraper
|
||||
"""
|
||||
import os
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import ScriptCreatorGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
@ -32,7 +35,7 @@ smart_scraper_graph = ScriptCreatorGraph(
|
||||
prompt="List me all the news with their description.",
|
||||
# also accepts a string with the already downloaded HTML code
|
||||
source="https://perinim.github.io/projects",
|
||||
config=graph_config
|
||||
config=graph_config,
|
||||
)
|
||||
|
||||
result = smart_scraper_graph.run()
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using ScriptCreatorGraph
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import List
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from scrapegraphai.graphs import ScriptCreatorGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
@ -14,13 +17,16 @@ load_dotenv()
|
||||
# Define the schema for the graph
|
||||
# ************************************************
|
||||
|
||||
|
||||
class Project(BaseModel):
|
||||
title: str = Field(description="The title of the project")
|
||||
description: str = Field(description="The description of the project")
|
||||
|
||||
|
||||
class Projects(BaseModel):
|
||||
projects: List[Project]
|
||||
|
||||
|
||||
# ************************************************
|
||||
# Define the configuration for the graph
|
||||
# ************************************************
|
||||
@ -28,10 +34,7 @@ class Projects(BaseModel):
|
||||
openai_key = os.getenv("OPENAI_APIKEY")
|
||||
|
||||
graph_config = {
|
||||
"llm": {
|
||||
"api_key": openai_key,
|
||||
"model": "openai/gpt-4o"
|
||||
},
|
||||
"llm": {"api_key": openai_key, "model": "openai/gpt-4o"},
|
||||
"library": "beautifulsoup",
|
||||
"verbose": True,
|
||||
}
|
||||
@ -45,7 +48,7 @@ script_creator_graph = ScriptCreatorGraph(
|
||||
# also accepts a string with the already downloaded HTML code
|
||||
source="https://perinim.github.io/projects",
|
||||
config=graph_config,
|
||||
schema=Projects
|
||||
schema=Projects,
|
||||
)
|
||||
|
||||
result = script_creator_graph.run()
|
||||
@ -57,4 +60,3 @@ print(result)
|
||||
|
||||
graph_exec_info = script_creator_graph.get_execution_info()
|
||||
print(prettify_exec_info(graph_exec_info))
|
||||
|
||||
|
||||
@ -8,4 +8,4 @@ SERP_API_KEY=your-serp-api-key-here
|
||||
MAX_SEARCH_RESULTS=10
|
||||
MAX_TOKENS=4000
|
||||
MODEL_NAME=gpt-4-1106-preview
|
||||
TEMPERATURE=0.7
|
||||
TEMPERATURE=0.7
|
||||
|
||||
@ -28,4 +28,4 @@ results = graph.search("your search query")
|
||||
|
||||
Required environment variables:
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
- `SERP_API_KEY`: Your SERP API key (optional)
|
||||
- `SERP_API_KEY`: Your SERP API key (optional)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
"""
|
||||
Example of Search Graph
|
||||
"""
|
||||
|
||||
from scrapegraphai.graphs import SearchGraph
|
||||
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
|
||||
|
||||
@ -25,8 +26,7 @@ graph_config = {
|
||||
# ************************************************
|
||||
|
||||
search_graph = SearchGraph(
|
||||
prompt="List me the best escursions near Trento",
|
||||
config=graph_config
|
||||
prompt="List me the best escursions near Trento", config=graph_config
|
||||
)
|
||||
|
||||
result = search_graph.run()
|
||||
|
||||
@ -1,23 +1,28 @@
|
||||
"""
|
||||
Example of Search Graph
|
||||
"""
|
||||
from scrapegraphai.graphs import SearchGraph
|
||||
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
|
||||
|
||||
from typing import List
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import List
|
||||
|
||||
from scrapegraphai.graphs import SearchGraph
|
||||
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
|
||||
|
||||
# ************************************************
|
||||
# Define the output schema for the graph
|
||||
# ************************************************
|
||||
|
||||
|
||||
class Dish(BaseModel):
|
||||
name: str = Field(description="The name of the dish")
|
||||
description: str = Field(description="The description of the dish")
|
||||
|
||||
|
||||
class Dishes(BaseModel):
|
||||
dishes: List[Dish]
|
||||
|
||||
|
||||
# ************************************************
|
||||
# Define the configuration for the graph
|
||||
# ************************************************
|
||||
@ -30,7 +35,7 @@ graph_config = {
|
||||
# "base_url": "http://localhost:11434", # set ollama URL arbitrarily
|
||||
},
|
||||
"verbose": True,
|
||||
"headless": False
|
||||
"headless": False,
|
||||
}
|
||||
|
||||
# ************************************************
|
||||
@ -38,9 +43,7 @@ graph_config = {
|
||||
# ************************************************
|
||||
|
||||
search_graph = SearchGraph(
|
||||
prompt="List me Chioggia's famous dishes",
|
||||
config=graph_config,
|
||||
schema=Dishes
|
||||
prompt="List me Chioggia's famous dishes", config=graph_config, schema=Dishes
|
||||
)
|
||||
|
||||
result = search_graph.run()
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
"""
|
||||
Example of Search Graph
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import SearchGraph
|
||||
|
||||
load_dotenv()
|
||||
@ -27,8 +30,7 @@ graph_config = {
|
||||
# ************************************************
|
||||
|
||||
search_graph = SearchGraph(
|
||||
prompt="List me Chioggia's famous dishes",
|
||||
config=graph_config
|
||||
prompt="List me Chioggia's famous dishes", config=graph_config
|
||||
)
|
||||
|
||||
result = search_graph.run()
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
"""
|
||||
Example of Search Graph
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import List
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from scrapegraphai.graphs import SearchGraph
|
||||
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
|
||||
|
||||
@ -14,13 +17,16 @@ load_dotenv()
|
||||
# Define the output schema for the graph
|
||||
# ************************************************
|
||||
|
||||
|
||||
class Dish(BaseModel):
|
||||
name: str = Field(description="The name of the dish")
|
||||
description: str = Field(description="The description of the dish")
|
||||
|
||||
|
||||
class Dishes(BaseModel):
|
||||
dishes: List[Dish]
|
||||
|
||||
|
||||
# ************************************************
|
||||
# Define the configuration for the graph
|
||||
# ************************************************
|
||||
@ -28,10 +34,7 @@ class Dishes(BaseModel):
|
||||
openai_key = os.getenv("OPENAI_APIKEY")
|
||||
|
||||
graph_config = {
|
||||
"llm": {
|
||||
"api_key": openai_key,
|
||||
"model": "openai/gpt-4o"
|
||||
},
|
||||
"llm": {"api_key": openai_key, "model": "openai/gpt-4o"},
|
||||
"max_results": 2,
|
||||
"verbose": True,
|
||||
}
|
||||
@ -41,9 +44,7 @@ graph_config = {
|
||||
# ************************************************
|
||||
|
||||
search_graph = SearchGraph(
|
||||
prompt="List me Chioggia's famous dishes",
|
||||
config=graph_config,
|
||||
schema=Dishes
|
||||
prompt="List me Chioggia's famous dishes", config=graph_config, schema=Dishes
|
||||
)
|
||||
|
||||
result = search_graph.run()
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using SmartScraper
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import SearchLinkGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
@ -27,8 +30,7 @@ graph_config = {
|
||||
# ************************************************
|
||||
|
||||
smart_scraper_graph = SearchLinkGraph(
|
||||
source="https://sport.sky.it/nba?gr=www",
|
||||
config=graph_config
|
||||
source="https://sport.sky.it/nba?gr=www", config=graph_config
|
||||
)
|
||||
|
||||
result = smart_scraper_graph.run()
|
||||
|
||||
@ -11,4 +11,4 @@ TEMPERATURE=0.7
|
||||
|
||||
# Speech Settings
|
||||
AUDIO_FORMAT=mp3
|
||||
SAMPLE_RATE=16000
|
||||
SAMPLE_RATE=16000
|
||||
|
||||
@ -28,4 +28,4 @@ text = graph.process("audio_file.mp3")
|
||||
|
||||
Required environment variables:
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
- `WHISPER_API_KEY`: Your Whisper API key (optional)
|
||||
- `WHISPER_API_KEY`: Your Whisper API key (optional)
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
"""
|
||||
"""
|
||||
Basic example of scraping pipeline using SpeechSummaryGraph
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from scrapegraphai.graphs import SpeechGraph
|
||||
from scrapegraphai.utils import prettify_exec_info
|
||||
|
||||
@ -28,11 +31,7 @@ graph_config = {
|
||||
"model": "openai/gpt-4o",
|
||||
"temperature": 0.7,
|
||||
},
|
||||
"tts_model": {
|
||||
"api_key": openai_key,
|
||||
"model": "tts-1",
|
||||
"voice": "alloy"
|
||||
},
|
||||
"tts_model": {"api_key": openai_key, "model": "tts-1", "voice": "alloy"},
|
||||
"output_path": output_path,
|
||||
}
|
||||
|
||||
|
||||
@ -8,4 +8,4 @@ TEMPERATURE=0.7
|
||||
|
||||
# XML Scraper Settings
|
||||
XPATH_TIMEOUT=30
|
||||
VALIDATE_XML=true
|
||||
VALIDATE_XML=true
|
||||
|
||||
@ -27,4 +27,4 @@ xml_data = graph.scrape("https://example.com/feed.xml")
|
||||
## Environment Variables
|
||||
|
||||
Required environment variables:
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<genre>Computer</genre>
|
||||
<price>44.95</price>
|
||||
<publish_date>2000-10-01</publish_date>
|
||||
<description>An in-depth look at creating applications
|
||||
<description>An in-depth look at creating applications
|
||||
with XML.</description>
|
||||
</book>
|
||||
<book id="bk102">
|
||||
@ -15,8 +15,8 @@
|
||||
<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
|
||||
<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">
|
||||
@ -25,8 +25,8 @@
|
||||
<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
|
||||
<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">
|
||||
@ -35,9 +35,9 @@
|
||||
<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
|
||||
<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">
|
||||
@ -46,8 +46,8 @@
|
||||
<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
|
||||
<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">
|
||||
@ -56,7 +56,7 @@
|
||||
<genre>Romance</genre>
|
||||
<price>4.95</price>
|
||||
<publish_date>2000-09-02</publish_date>
|
||||
<description>When Carla meets Paul at an ornithology
|
||||
<description>When Carla meets Paul at an ornithology
|
||||
conference, tempers fly as feathers get ruffled.</description>
|
||||
</book>
|
||||
<book id="bk107">
|
||||
@ -65,7 +65,7 @@
|
||||
<genre>Romance</genre>
|
||||
<price>4.95</price>
|
||||
<publish_date>2000-11-02</publish_date>
|
||||
<description>A deep sea diver finds true love twenty
|
||||
<description>A deep sea diver finds true love twenty
|
||||
thousand leagues beneath the sea.</description>
|
||||
</book>
|
||||
<book id="bk108">
|
||||
@ -84,7 +84,7 @@
|
||||
<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
|
||||
Uncertainty Device, James Salway discovers the problems
|
||||
of being quantum.</description>
|
||||
</book>
|
||||
<book id="bk110">
|
||||
@ -93,7 +93,7 @@
|
||||
<genre>Computer</genre>
|
||||
<price>36.95</price>
|
||||
<publish_date>2000-12-09</publish_date>
|
||||
<description>Microsoft's .NET initiative is explored in
|
||||
<description>Microsoft's .NET initiative is explored in
|
||||
detail in this deep programmer's reference.</description>
|
||||
</book>
|
||||
<book id="bk111">
|
||||
@ -102,8 +102,8 @@
|
||||
<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,
|
||||
<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">
|
||||
@ -113,8 +113,8 @@
|
||||
<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
|
||||
looking at how Visual Basic, Visual C++, C#, and ASP+ are
|
||||
integrated into a comprehensive development
|
||||
environment.</description>
|
||||
</book>
|
||||
</catalog>
|
||||
</catalog>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user