Skip to main content

A web scraping library based on LangChain which uses LLM and direct graph logic to create scraping pipelines.

Project description

🕷️ ScrapeGraphAI: You Only Scrape Once

Downloads linting: pylint Pylint License: MIT

ScrapeGraphAI is a web scraping python library which uses LLM and direct graph logic to create scraping pipelines for websites, documents and XML files. Just say which information you want to extract and the library will do it for you!

Scrapegraph-ai Logo

🚀 Quick install

The reference page for Scrapegraph-ai is avaible on the official page of pypy: pypi.

pip install scrapegraphai

🔍 Demo

Official streamlit demo:

My Skills

Try it directly on the web using Google Colab:

Open In Colab

Follow the procedure on the following link to setup your OpenAI API key: link.

📖 Documentation

The documentation for ScrapeGraphAI can be found here.

Check out also the docusaurus documentation.

💻 Usage

Case 1: Extracting informations using a local LLM

You can use the SmartScraper class to extract information from a website using a prompt.

The SmartScraper class is a direct graph implementation that uses the most common nodes present in a web scraping pipeline. For more information, please see the documentation.


Case 2: Extracting informations using Openai model

from scrapegraphai.graphs import SmartScraperGraph
OPENAI_API_KEY = "YOUR_API_KEY"

# Define the configuration for the graph
graph_config = {
    "llm": {
        "api_key": OPENAI_API_KEY,
        "model": "gpt-3.5-turbo",
    },
}

# Create the SmartScraperGraph instance
smart_scraper_graph = SmartScraperGraph(
    prompt="List me all the news with their description.",
    file_source="https://perinim.github.io/projects/",  # also accepts a string with the already downloaded HTML code as string format
    config=graph_config
)

result = smart_scraper_graph.run()
print(result)

Case 3: Extracting informations using Gemini

from scrapegraphai.graphs import SmartScraperGraph
GOOGLE_APIKEY = "YOUR_API_KEY"

# Define the configuration for the graph
graph_config = {
    "llm": {
        "api_key": GOOGLE_APIKEY,
        "model": "gemini-pro",
    },
}

# Create the SmartScraperGraph instance
smart_scraper_graph = SmartScraperGraph(
    prompt="List me all the quotes, authors and tags ",
    file_source="http://quotes.toscrape.com",  # also accepts a string with the already downloaded HTML code as string format
    config=graph_config
)

result = smart_scraper_graph.run()
print(result)

The output for alle 3 the cases will be a dictionary with the extracted information, for example:

{
    'titles': [
        'Rotary Pendulum RL'
        ],
    'descriptions': [
        'Open Source project aimed at controlling a real life rotary pendulum using RL algorithms'
        ]
}

🤝 Contributing

Fell free to contribute and join our Discord server to discuss with us improvements and give us suggestions!

For more information, please see the contributing guidelines.

My Skills My Skills My Skills

❤️ Contributors

Contributors

🎓 Citations

If you have used our library for research purposes please quote us with the following reference:

  @misc{scrapegraph-ai,
    author = {Marco Perini, Lorenzo Padoan, Marco Vinciguerra},
    title = {Scrapegraph-ai},
    year = {2024},
    url = {https://github.com/VinciGit00/Scrapegraph-ai},
    note = {A Python library for scraping data from graphs}
  }

Authors

Authors Logos

Contact Info
Marco Vinciguerra Linkedin Badge
Marco Perini Linkedin Badge
Lorenzo Padoan Linkedin Badge

📜 License

ScrapeGraphAI is licensed under the MIT License. See the LICENSE file for more information.

Acknowledgements

  • We would like to thank all the contributors to the project and the open-source community for their support.
  • ScrapeGraphAI is meant to be used for data exploration and research purposes only. We are not responsible for any misuse of the library.

Project details


Release history Release notifications | RSS feed

This version

0.1.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scrapegraphai-0.1.1.tar.gz (26.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scrapegraphai-0.1.1-py3-none-any.whl (40.8 kB view details)

Uploaded Python 3

File details

Details for the file scrapegraphai-0.1.1.tar.gz.

File metadata

  • Download URL: scrapegraphai-0.1.1.tar.gz
  • Upload date:
  • Size: 26.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.7 Darwin/23.3.0

File hashes

Hashes for scrapegraphai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 527711a46ea3d2c37ed8909f5ec70ec5d4c95322e7c88a557d8d2e2f1304ad4a
MD5 16f11e55e0471152d785f1a6ce7e2325
BLAKE2b-256 6bbc01e34e10a55c8f54951206186e440bfd995976e108507ad6d0b99f2576d4

See more details on using hashes here.

File details

Details for the file scrapegraphai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: scrapegraphai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 40.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.7 Darwin/23.3.0

File hashes

Hashes for scrapegraphai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa196ab2e7bc692cb57b7bc786a23a679eac96744b05970363ada5c7b91476a5
MD5 4aabdcab26de3a3b00d501e077afab5b
BLAKE2b-256 e5451353a181a5dd1f11d92f1ae8a4b3783a95024fc5badcb2e0f1c57e6acfd2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page