Skip to content

Commit e241973

Browse files
committed
Remove unneccesary writer.py.
1 parent 380ed69 commit e241973

3 files changed

Lines changed: 7 additions & 33 deletions

File tree

aiohttp_aiofiles_tutorial/fetcher.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from aiohttp import ClientError, ClientSession, InvalidURL
44
from logger import LOGGER
55

6-
from .writer import write_to_outfile
6+
from .parser import parse_html_page_metadata
77

88

99
async def fetch_url_and_save_data(
@@ -27,7 +27,9 @@ async def fetch_url_and_save_data(
2727
if resp.status != 200:
2828
pass
2929
html = await resp.text()
30-
await write_to_outfile(html, url, outfile, total_count, i)
30+
page_metadata = await parse_html_page_metadata(html, url)
31+
await outfile.write(f"{page_metadata}\n")
32+
LOGGER.info(f"Fetched URL {i} of {total_count}: {page_metadata}")
3133
except InvalidURL as e:
3234
LOGGER.error(f"Unable to fetch invalid URL `{url}`: {e}")
3335
except ClientError as e:

aiohttp_aiofiles_tutorial/parser.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@ async def parse_html_page_metadata(html: str, url: str) -> str:
2323
.replace('"', "`")
2424
.replace("'", "`")
2525
)
26-
primary_tag = (
27-
soup.head
28-
.select_one("meta[property='article:tag']")
29-
.get("content")
26+
primary_tag = soup.head.select_one("meta[property='article:tag']").get(
27+
"content"
3028
)
3129
published_at = (
32-
soup.head
33-
.select_one("meta[property='article:published_time']")
30+
soup.head.select_one("meta[property='article:published_time']")
3431
.get("content")
3532
.split("T")[0]
3633
)

aiohttp_aiofiles_tutorial/writer.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)