Page Analyzer is a web application built with Flask that allows users to add URLs and analyze them for various attributes like title, h1, and meta description. It uses BeautifulSoup and requests libraries to fetch and parse the content of the pages.
- Add URLs to the database
- Fetch and display page attributes like title, h1, and description
- Check URLs for updates
- Display the history of checks for each URL
- Python 3.10+
- PostgreSQL
- Flask
- BeautifulSoup
- requests
- dotenv
-
Clone the repository:
git clone https://github.com/SvamiBog/python-project-83.git cd python-project-83 -
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Set up the database: Ensure you have PostgreSQL installed and create a database for the project.
CREATE DATABASE page_analyzer;
Update the
.envfile with your database credentials:DATABASE_URL=postgresql://<username>:<password>@localhost/page_analyzer SECRET_KEY=<your_secret_key> -
Run the database migrations:
python -c "from db import create_tables; create_tables()" -
Run the application:
flask run
The application will be available at http://127.0.0.1:5000/.
-
Add a URL:
- Enter the URL you want to analyze in the input field on the home page and submit.
- The URL will be added to the database, and you will be redirected to the URL's detail page.
-
Check a URL:
- On the URL's detail page, click the "Запустить проверку" button to fetch and display the latest attributes of the page.
- The results of the check will be stored and displayed in a history table.
To run the tests, use the following command:
pytest