This project is a FastAPI application that scrapes news articles, summarizes them, downloads the images, and posts the news to both Facebook and Instagram. It uses MongoDB Atlas to store and check if news articles have already been posted to avoid duplicates.
This project demonstrates how to build a FastAPI application with web scraping, image handling, and integration with external APIs. It also showcases using MongoDB Atlas for data storage.
- Scrapes the latest news articles from a specified website.
- Downloads images associated with the news articles.
- Summarizes article content using Google's Generative AI.
- Posts the news articles and images to a specified Facebook page and Instagram account.
- Uses MongoDB Atlas to store posted news URLs to prevent duplicate postings.
- Python 3.x
- MongoDB Atlas account
- Facebook page and access token
- Instagram account and access token
-
Clone the repository:
git clone https://github.com/AnamolZ/NewsBridge.git cd NewsBridge
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
Create a
.env
file in the root directory -
Run the application:
uvicorn main:app --reload
main.py
: The main FastAPI application file.requirements.txt
: The Python dependencies..env
: Environment variables file (not included in the repository).
-
Start the FastAPI server:
uvicorn main:app --reload
-
Access the news scraping endpoint (if implemented):
http://localhost:8000/news
fastapi
: A modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.requests
: A simple, yet elegant HTTP library.beautifulsoup4
: A library for parsing HTML and XML documents.pydantic
: Data validation and settings management using Python type annotations.pymongo
: A Python driver for MongoDB.google-generativeai
: A library for accessing Google's generative AI models.Pillow
: The Python Imaging Library adds image processing capabilities to your Python interpreter.uvicorn
: A lightning-fast ASGI server implementation, usinguvloop
andhttptools
.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.