Skip to content

dantexaugusto/AI_webscraper_Aider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web Scraper with LLM Integration

Overview

This project is a tool that combines web scraping with language model analysis. It fetches content from a specified URL, extracts its textual information using BeautifulSoup, and then sends the content to an OpenAI LLM (using the model "gpt-4o") for a comprehensive analysis based on custom instructions provided by the user. The final analysis output is saved to output.txt.

This project was executed from start to finish using the terminal-based programming assistance software Aider (https://aider.chat/) which connected to the OpenAI "o3-mini" model via its API.

Features

  • Web Scraping: Utilizes the requests library to retrieve web pages and BeautifulSoup from beautifulsoup4 for parsing HTML.
  • LLM Analysis: Integrates with OpenAI’s API (through the openai package) to process and analyze scraped text.
  • Environment Configuration: Leverages python-dotenv to securely manage sensitive configurations like the OpenAI API key through a .env file.
  • Output Storage: Saves the processed analysis results to a file (output.txt) for later review.

File Structure

  • webscraper.py:

    • Loads environment variables from .env.
    • Prompts the user for a URL and an instruction prompt for the analysis.
    • Scrapes the provided URL and extracts text content.
    • Sends the text along with developer instructions to the OpenAI API.
    • Writes the LLM’s output to output.txt.
  • output.txt:
    Stores the result of the LLM analysis.

  • requirements.txt:
    Lists all necessary dependencies:

    • requests
    • beautifulsoup4
    • python-dotenv
    • openai
  • .gitignore:
    Specifies files and directories to be ignored by Git (read-only, not modified by this project).

Setup and Installation

  1. Clone the Repository:

    git clone <repository_url>
    cd <repository_directory>
  2. Install Dependencies:

    pip install -r requirements.txt
  3. Environment Configuration:

    • Create a .env file in the project root directory.
    • Add your OpenAI API key:
      OPENAI_API_KEY=your_api_key_here
      
  4. Make the Script Executable (if necessary):

    chmod +x webscraper.py

Usage

Run the scraper by executing:

./webscraper.py

You will be prompted to:

  • Enter the URL to scrape.
  • Enter the prompt instructions for the LLM analysis.

The analysis results will be written to output.txt and a confirmation message will be printed.

Contributing

Contributions are welcome! Please follow these steps:

  • Fork the repository.
  • Create a new branch for your changes.
  • Submit a pull request with a clear description of your changes.

License

This project is licensed under the MIT License.

MIT License

Copyright (c) 2025 polimat[IA]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files, to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

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.

Contact

For further questions or contributions, please contact the project maintainer.

About

AI webscraper totalmente desenvolvido com Aider

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages