Skip to content

Commit

Permalink
🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
HA authored and HA committed Feb 13, 2024
1 parent 376be52 commit fc4e01e
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions stock_view/data_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,17 @@ def latest_news():
soup = Soup(html)
date = soup.find("div", {"class": "date"})
date_title_url = []
for i in range(1, len(date)):
date_title_url.append(
{
"date": datetime.strptime(date[i].find("a").text, "%B %d, %Y").strftime(
"%d-%m-%Y"
),
"title": date[i].find("a").attrs["title"],
"url": date[i].find("a").attrs["href"],
}
)
return date_title_url
try:
for i in range(1, len(date)):
date_title_url.append(
{
"date": datetime.strptime(
date[i].find("a").text, "%B %d, %Y"
).strftime("%d-%m-%Y"),
"title": date[i].find("a").attrs["title"],
"url": date[i].find("a").attrs["href"],
}
)
return date_title_url
except Exception as e:
print(f"Market news data not available now ! {e}")

0 comments on commit fc4e01e

Please sign in to comment.