-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added errors page and routes, moved html parser, fixed db.py app.py
- Loading branch information
1 parent
e9f94bb
commit 6504560
Showing
9 changed files
with
411 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,9 @@ build: | |
lint: | ||
poetry run flake8 page_analyzer | ||
|
||
test: | ||
poetry run pytest | ||
|
||
selfcheck: | ||
poetry check | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from bs4 import BeautifulSoup | ||
|
||
|
||
def parse_page(response_text): | ||
html_data = BeautifulSoup(response_text, 'html.parser') | ||
page_data = {'title': html_data.title.string if html_data.title else None, | ||
'h1': html_data.h1.string if html_data.h1 else None} | ||
|
||
description = html_data.find('meta', {'name': 'description'}) | ||
if description: | ||
description = description.get('content') | ||
|
||
page_data['description'] = description | ||
|
||
return page_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% extends "layout.html" %} | ||
{% block content %} | ||
<h1>Страница не найдена</h1> | ||
<p>Проверьте корректность адреса</p> | ||
<a href="{ url_for('page_analyzer') }">Вернуться на главную</a> | ||
{% endblock %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% extends "layout.html" %} | ||
{% block content %} | ||
<h1>Ошибка сервера</h1> | ||
<p>Извините, попробуте выполнить ваш запрос позже</p> | ||
<a href="{ url_for('page_analyzer') }">Вернуться на главную</a> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.