This is a microservice designed to fetch and serve news articles using FastAPI, Requests, and BeautifulSoup. It provides a simple and efficient way to retrieve news articles about laptops.
- FastAPI: Utilizes the FastAPI framework for creating a fast and modern API with automatic documentation generation.
- Requests: Makes HTTP requests to external news sources to fetch the latest articles.
- Beautiful Soup: Parses and extracts relevant information from the HTML content of news articles.
- Asynchronous: Takes advantage of asynchronous programming for efficient handling of multiple requests.
-
Clone the repository:
git clone https://github.com/LLkaia/news-laptops-ms.git cd news-laptops-ms
-
Create a virtual environment (optional but recommended):
python -m venv venv
-
Activate the virtual environment:
-
On Windows:
.\venv\Scripts\activate
-
On Unix or MacOS:
source venv/bin/activate
-
-
Install the dependencies:
pip install -r requirements.txt
-
Run the FastAPI application:
python main
-
Open your web browser and navigate to
http://localhost:8000/docs
to access the Swagger documentation. Here, you can test the different API endpoints and see example requests and responses.
-
/news/search
: Search articles about laptops.-
Example:
http://localhost:8000/news/search?find=acer+aspire+7+review
-
-
/news/{id}
: Show concrete article.-
Example:
http://localhost:8000/news/657c1690f253079b6f3ed074
-