Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions backend/feed_engine/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@
from dataclasses import dataclass
from urllib.error import HTTPError, URLError
from urllib.parse import urlsplit
from urllib.request import Request, urlopen
from urllib.request import HTTPSHandler, Request, build_opener

import certifi

from feed_engine.errors import FeedEngineError

Expand Down Expand Up @@ -178,10 +180,16 @@ def _fetch_feed_sync(

request = Request(url, headers=headers)

if url.startswith("https://"):
ssl_context = ssl.create_default_context(cafile=certifi.where())
opener = build_opener(HTTPSHandler(context=ssl_context))
else:
opener = build_opener()

print("[FETCH START]", url)

try:
with urlopen(request, timeout=timeout_seconds) as response:
with opener.open(request, timeout=timeout_seconds) as response:
print("[FETCH OK]", response.status)

return FetchResponse(
Expand Down
1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ dependencies = [
"bleach>=6.2",
"lxml>=5.3",
"markdownify>=1.1",
"certifi>=2024",
]

[dependency-groups]
Expand Down
2 changes: 2 additions & 0 deletions backend/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading