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

ScrapeGraphAI is a web scraping python library based on LangChain which uses LLM and direct graph logic to create scraping pipelines. Just say which information you want to extract and the library will do it for you!

Scrapegraph-ai Logo

🚀 Quick install

pip install scrapegraphai

🔍 Demo

Try out ScrapeGraphAI in your browser:

Open in GitHub Codespaces

📖 Documentation

The documentation for ScrapeGraphAI can be found here. Behind this there is also the docusaurus documentation here.

Setup the api keys

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

💻 Usage

Case 1: Extracting information using a prompt

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.

from scrapegraphai.graphs import SmartScraper

OPENAI_API_KEY = "YOUR_API_KEY"

llm_config = {
    "api_key": OPENAI_API_KEY,
    "model_name": "gpt-3.5-turbo",
}

smart_scraper = SmartScraper("List me all the titles and project descriptions",
                             "https://perinim.github.io/projects/", llm_config)

answer = smart_scraper.run()
print(answer)

The output 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

Contributions are welcome! Please check out the todos below, and feel free to open a pull request. For more information, please see the contributing guidelines.

After installing and activating the virtual environment, please remember to install the library using the "dev" extra parameter to have the extra dependencies for development.

pip install -e .[dev]

Contributors

Contributors

Authors

Authors Logos

📜 License

ScrapeGraphAI is licensed under the Apache 2.0 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.

Thanks to:

  • nicolapiazzalunga for having inspired us to the functions: scrapegraph/convert_to_json.py and scrapegraph/convert_to_csv.py

Project details


Release history Release notifications | RSS feed

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.0.2.tar.gz (16.7 kB view hashes)

Uploaded Source

Built Distribution

scrapegraphai-0.0.2-py3-none-any.whl (22.1 kB view hashes)

Uploaded Python 3

Supported by

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