File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 1
1
"""Interact with the Real Python feed."""
2
2
# Standard library imports
3
- from typing import Dict , List # noqa
3
+ from typing import Dict , List
4
4
5
5
# Third party imports
6
6
import feedparser
@@ -21,8 +21,17 @@ def _feed(url: str = URL) -> feedparser.FeedParserDict:
21
21
22
22
def get_site (url : str = URL ) -> str :
23
23
"""Get name and link to website of the feed."""
24
- info = _feed (url ).feed
25
- return f"{ info .title } ({ info .link } )"
24
+ info = _feed (url )
25
+ if exception := info .get ("bozo_exception" ):
26
+ message = f"Could not read feed at { url } "
27
+ if "CERTIFICATE_VERIFY_FAILED" in str (exception ):
28
+ message += (
29
+ ".\n \n You may need to manually install certificates by running "
30
+ "`Install Certificates` in your Python installation folder. "
31
+ "See https://realpython.com/installing-python/"
32
+ )
33
+ raise SystemExit (message )
34
+ return f"{ info .feed .title } ({ info .feed .link } )"
26
35
27
36
28
37
def get_article (article_id : str , links : bool = False , url : str = URL ) -> str :
You can’t perform that action at this time.
0 commit comments