Skip to content

Commit ebc813f

Browse files
committed
Minor parsing and metadata changes.
1 parent 57f8293 commit ebc813f

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
![Aiohttp](https://img.shields.io/badge/Aiohttp-v^3.8.1-blue.svg?longCache=true&logo=python&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
66
![Aiofiles](https://img.shields.io/badge/Aiofiles-v^0.8.0-blue.svg?longCache=true&logo=python&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
77
![GitHub Last Commit](https://img.shields.io/github/last-commit/google/skia.svg?style=flat-square&colorA=4c566a&colorB=a3be8c&logo=GitHub)
8-
[![GitHub Issues](https://img.shields.io/github/issues/hackersandslackers/aiohttp-aiofiles-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-blueprint-tutorial/issues)
9-
[![GitHub Stars](https://img.shields.io/github/stars/hackersandslackers/aiohttp-aiofiles-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-blueprint-tutorial/stargazers)
10-
[![GitHub Forks](https://img.shields.io/github/forks/hackersandslackers/aiohttp-aiofiles-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-blueprint-tutorial/network)
8+
[![GitHub Issues](https://img.shields.io/github/issues/hackersandslackers/aiohttp-aiofiles-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/aiohttp-aiofiles-tutorial/issues)
9+
[![GitHub Stars](https://img.shields.io/github/stars/hackersandslackers/aiohttp-aiofiles-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/aiohttp-aiofiles-tutorial/stargazers)
10+
[![GitHub Forks](https://img.shields.io/github/forks/hackersandslackers/aiohttp-aiofiles-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/aiohttp-aiofiles-tutorial/network)
1111

1212
![Asyncio](.github/aiohttp@2x.jpg)
1313

aiohttp_aiofiles_tutorial/parser.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Parse metadata from raw HTML."""
12
from bs4 import BeautifulSoup
23
from logger import LOGGER
34

@@ -13,17 +14,18 @@ async def parse_html_page_data(html: str, url: str) -> str:
1314
"""
1415
try:
1516
soup = BeautifulSoup(html, "html.parser")
16-
title = soup.title.string.replace(",", "")
17+
title = soup.title.string.replace(",", ";")
1718
description = (
1819
soup.head.select_one("meta[name=description]")
1920
.get("content")
20-
.replace(",", "")
21-
.replace('"', "")
21+
.replace(",", ";")
22+
.replace('"', "`")
23+
.replace("'", "`")
2224
)
2325
primary_tag = soup.head.select_one("meta[property='article:tag']").get("content")
2426
published_at = soup.head.select_one("meta[property='article:published_time']").get(
2527
"content"
26-
)
28+
).split("T")[0]
2729
if primary_tag is None:
2830
primary_tag = ""
2931
return f"{title}, {description}, {primary_tag}, {url}, {published_at}"

aiohttp_aiofiles_tutorial/tests/test_parser.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
"""Test metadata parser accuracy with local HTML file."""
2-
import asyncio
3-
42
import aiofiles
53
import pytest
64
from aiohttp_aiofiles_tutorial.parser import parse_html_page_data
@@ -11,11 +9,11 @@
119
async def sample_page_metadata():
1210
"""Expected metadata to be returned from parsing `intro_to_asyncio.html`"""
1311
title = "Intro to Asynchronous Python with Asyncio"
14-
description = "Execute multiple tasks concurrently in Python with Asyncio: Python's built-in async library."
12+
description = "Execute multiple tasks concurrently in Python with Asyncio: Python`s built-in async library."
1513
tag = "Python"
1614
url = "https://hackersandslackers.com/intro-to-asyncio-concurrency/"
17-
published_at = "2022-01-04T07:37:00.000-05:00"
18-
return ", ".join([title, description, tag, url, published_at]) + ","
15+
published_at = "2022-01-04"
16+
return ", ".join([title, description, tag, url, published_at])
1917

2018

2119
@pytest.mark.asyncio

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22
name = "Async HTTP Requests with Aiohttp & Aiofiles"
33
version = "0.1.0"
4-
description = "Handle thousands of HTTP requests, disk writes, and other I/O-bound tasks with Python's quintessential async libraries."
4+
description = "Handle mass HTTP requests, disk writes, and other I/O-bound tasks with Python's quintessential async libraries."
55
authors = ["Todd Birchard <todd@hackersandslackers.com>"]
66
maintainers = ["Todd Birchard <todd@hackersandslackers.com>"]
77
license = "MIT"
@@ -49,7 +49,7 @@ build-backend = "poetry.masonry.api"
4949

5050
[tool.isort]
5151
profile = "black"
52-
src_paths = ["asyncio_aiohttp_aiofiles_tutorial"]
52+
src_paths = ["aiohttp_aiofiles_tutorial"]
5353

5454
[tool.black]
5555
line-length = 100

0 commit comments

Comments
 (0)