Skip to content

Python scraper based on AI

UPD readthedocs

Lorenzo Padoan1bb2a1109903
diff --git a/docs/source/getting_started/examples.rst b/docs/source/getting_started/examples.rst
new file mode 100644
index 00000000..1fa9bcd6
--- /dev/null
+++ b/docs/source/getting_started/examples.rst
@@ -0,0 +1,121 @@
+Overview
+========
+
+Here some example of the different ways to scrape with ScrapegraphAI
+
+OpenAI models
+^^^^^^^^^^^^^
+
+.. code-block:: python
+
+ import os
+ from dotenv import load_dotenv
+ from scrapegraphai.graphs import SmartScraperGraph
+ from scrapegraphai.utils import prettify_exec_info
+
+ load_dotenv()
+
+ openai_key = os.getenv("OPENAI_APIKEY")
+
+ graph_config = {
+ "llm": {
+ "api_key": openai_key,
+ "model": "gpt-3.5-turbo",
+ },
+ }
+
+ # ************************************************
+ # Create the SmartScraperGraph instance and run it
+ # ************************************************
+
+ 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
+ )
+
+ result = smart_scraper_graph.run()
+ print(result)
+
+
+OpenAI models
+^^^^^^^^^^^^^
+
+.. code-block:: python
+
+ import os
+ from dotenv import load_dotenv
+ from scrapegraphai.graphs import SmartScraperGraph
+ from scrapegraphai.utils import prettify_exec_info
+
+ load_dotenv()
+
+ openai_key = os.getenv("OPENAI_APIKEY")
+
+ graph_config = {
+ "llm": {
+ "api_key": openai_key,
+ "model": "gpt-3.5-turbo",
+ },
+ }
+
+ # ************************************************
+ # Create the SmartScraperGraph instance and run it
+ # ************************************************
+
+ 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
+ )
+
+ result = smart_scraper_graph.run()
+ print(result)
+
+Local models
+^^^^^^^^^^^^^
+
+Remember to have installed in your pc ollama `ollama <https://ollama.com/>`
+Remember to pull the right model for LLM and for the embeddings, like:
+.. code-block:: bash
+
+ ollama pull llama3
+
+After that, you can run the following code, using only your machine resources brum brum brum:
+
+.. code-block:: python
+
+ from scrapegraphai.graphs import SmartScraperGraph
+ from scrapegraphai.utils import prettify_exec_info
+
+ graph_config = {
+ "llm": {
+ "model": "ollama/mistral",
+ "temperature": 1,
+ "format": "json", # Ollama needs the format to be specified explicitly
+ "model_tokens": 2000, # depending on the model set context length
+ "base_url": "http://localhost:11434", # set ollama URL of the local host (YOU CAN CHANGE IT, if you have a different endpoint
+ },
+ "embeddings": {
+ "model": "ollama/nomic-embed-text",
+ "temperature": 0,
+ "base_url": "http://localhost:11434", # set ollama URL
+ }
+ }
+
+ # ************************************************
+ # Create the SmartScraperGraph instance and run it
+ # ************************************************
+
+ smart_scraper_graph = SmartScraperGraph(
+ 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
+ )
+
+ result = smart_scraper_graph.run()
+ print(result)
+
diff --git a/docs/source/getting_started/installation.rst b/docs/source/getting_started/installation.rst
index 6ba6c7d9..9dc896d6 100644
--- a/docs/source/getting_started/installation.rst
+++ b/docs/source/getting_started/installation.rst
@@ -8,77 +8,19 @@ Prerequisites
^^^^^^^^^^^^^
- `Python 3.8+ <https://www.python.org/downloads/>`_
-- `Visual Studio Code <https://code.visualstudio.com/download>`_ or IDE of your choice
+- `pip <https://pip.pypa.io/en/stable/getting-started/>`
+- `ollama <https://ollama.com/>` *optional for local models
-External dependencies
-^^^^^^^^^^^^^^^^^^^^^
-Windows
-+++++++
-
-Insert external dependencies for Windows if there are any.
-
-Linux
-++++++
-
-You don't need to install any external dependencies.
-
-Clone the repository
+Install the library
^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
- git clone https://github.com/VinciGit00/yoso-ai.git
- cd AmazScraper
-
-Create a virtual environment
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-It is recommended to create a virtual environment to install the dependencies in order to avoid conflicts with other projects.
-
-.. code-block:: bash
-
- python -m venv venv
- # python3 -m venv venv
-
-Activate the virtual environment
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-All the commands must be executed in the virtual environment. If you are not familiar with virtual environments, please read the `Python Virtual Environments: A Primer <https://realpython.com/python-virtual-environments-a-primer/>`_ article.
-
-To activate the virtual environment, run the following command:
-
-.. code-block:: bash
-
- # Windows
- .\venv\Scripts\activate
- # Linux
- source venv/bin/activate
-
-Install the dependencies
-^^^^^^^^^^^^^^^^^^^^^^^^
-
-In the **requirements.txt** file you will find all the dependencies needed to run the code. To install them, run the following command:
-
-.. code-block:: bash
-
- pip install -r requirements.txt
- # pip3 install -r requirements.txt
-
-Test the installation
-^^^^^^^^^^^^^^^^^^^^^
-
-- Let's test if the installation was successful. Run the following command:
+ pip install scrapegraphai
- .. code-block:: bash
- python some_example.py
- # python3 .some_example.py
+As simple as that! You are now ready to scrape gnamgnamgnam 👿👿👿
-- Let's test if the modules works. Run the following command:
- .. code-block:: bash
- python -m examples.values_scraping
- # or
- python -m examples.html_scraping
\ No newline at end of file
diff --git a/docs/source/index.rst b/docs/source/index.rst
index 64936249..276efc4a 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -21,6 +21,7 @@ The following sections will guide you through the installation process and the u
:caption: Getting Started
getting_started/installation
+ getting_started/examples
modules/modules
Indices and tables
diff --git a/docs/source/introduction/overview.rst b/docs/source/introduction/overview.rst
index ecf5320a..46ed21a5 100644
--- a/docs/source/introduction/overview.rst
+++ b/docs/source/introduction/overview.rst
@@ -1,24 +1,20 @@
-Overview
+Overview
========
-This is an open source project aimed at developing a scraping library using LLM through Langchain.
-The goal is to be able to scrape data using natural language queries and store them in a structured format.
+In a world where web pages are constantly changing and in a data-hungry world there is a need for a new generation of scrapers, and this is where ScrapegraphAI was born.
+An opensource library with the aim of starting a new era of scraping tools that are more flexible and require less maintenance by developers, with the use of LLMs.
-.. image:: ../../assets/apikey_1.png
+.. image:: ../../assets/scrapegraphai_logo.png
:align: center
- :width: 400px
- :alt: OpenAI Key
-
-.. image:: ../../assets/apikey_2.png
- :align: center
- :width: 400px
- :alt: OpenAI Key
+ :width: 100px
+ :alt: ScrapegraphAI
-.. image:: ../../assets/apikey_3.png
- :align: center
- :width: 400px
- :alt: OpenAI Key
-.. image:: ../../assets/apikey_4.png
- :align: center
- :width: 400px
- :alt: OpenAI Key
\ No newline at end of file
+Why ScrapegraphAI?
+==================
+
+ScrapegraphAI in our vision represents a significant step forward in the field of web scraping, offering an open-source solution designed to meet the needs of a constantly evolving web landscape. Here's why ScrapegraphAI stands out:
+
+Flexibility and Adaptability
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+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.
+This flexibility ensures that scrapers remain functional even when website layouts change.