Skip to content

Commit

Permalink
add .encode('ascii', 'ignore').decode('ascii')
Browse files Browse the repository at this point in the history
  • Loading branch information
asepscareer committed Aug 27, 2024
1 parent cc1ce50 commit 1fd7d13
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ycnbc/news/news_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def trending(self):
for i in trending_news:
text = i.xpath(".//a/text()")
link = list(i.iterlinks())[0][2] if list(i.iterlinks()) else None
title.append(' '.join(text))
title.append(' '.join(text).encode('ascii', 'ignore').decode('ascii'))
source.append(link)

return {
Expand Down Expand Up @@ -91,7 +91,7 @@ def latest(self):
text = rs.xpath(".//a/text()")
posttime_ = rs.xpath(".//span/time/text()")

title.append(' '.join(text))
title.append(' '.join(text).encode('ascii', 'ignore').decode('ascii'))
posttime.append(' '.join(posttime_))

return {
Expand Down Expand Up @@ -121,7 +121,7 @@ def by_category(self, category):
news_elements = tree.cssselect('.Card-titleContainer a.Card-title')
post_time_elements = tree.cssselect('span.Card-time')
for news, post_time in zip(news_elements, post_time_elements):
headlines.append(news.text.strip())
headlines.append(news.text.strip().encode('ascii', 'ignore').decode('ascii'))
links.append(news.get('href'))
post_times.append(post_time.text.strip())

Expand Down

0 comments on commit 1fd7d13

Please sign in to comment.