Skip to content

Commit

Permalink
Update rthk.py
Browse files Browse the repository at this point in the history
  • Loading branch information
raileo98 authored Oct 17, 2024
1 parent 0887b9f commit d3514a9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions code/rthk.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async def process_category(category, url):
logging.error(f'{category} 出現未知錯誤')
return

soup = BeautifulSoup(web_content, 'html.parser')
soup = BeautifulSoup(web_content, 'lxml')

fg = FeedGenerator()
fg.title(categories_data[category]['title'])
Expand All @@ -211,7 +211,7 @@ async def process_category(category, url):

rss_str = fg.rss_str()

soup_rss = BeautifulSoup(rss_str, 'xml')
soup_rss = BeautifulSoup(rss_str, 'lxml-xml')

for item in soup_rss.find_all('item'):
if item.description is not None:
Expand Down Expand Up @@ -253,7 +253,7 @@ async def process_article(fg, category, article):

article_response = await get_response(articleLink)
article_content = article_response.text
article_soup = BeautifulSoup(article_content, 'html.parser')
article_soup = BeautifulSoup(article_content, 'lxml')

feedDescription = article_soup.select_one('.itemFullText').prettify()

Expand Down Expand Up @@ -336,7 +336,7 @@ async def process_article(fg, category, article):

feedDescription = f'{imgHtml} <br> {feedDescription} <br><hr> <p>原始網址 Original URL:<a href="{articleLink}" rel="nofollow">{articleLink}</a></p> <p>© rthk.hk</p> <p>電子郵件 Email: <a href="mailto:cnews@rthk.hk" rel="nofollow">cnews@rthk.hk</a></p>'

feedDescription = BeautifulSoup(feedDescription, 'html.parser').prettify()
feedDescription = BeautifulSoup(feedDescription, 'lxml').prettify()

fe.title(articleTitle)
fe.link(href=articleLink)
Expand Down

0 comments on commit d3514a9

Please sign in to comment.