Skip to content

Commit

Permalink
🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
HA authored and HA committed Apr 8, 2024
1 parent fc4e01e commit 0c15615
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions stock_view/data_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,21 +265,24 @@ def latest_news():
Scrape stock news and links
"""
# now_date = datetime.now().today().strftime("%d-%m-%Y")
html = get("https://stocksng.com/category/business-economy/")
soup = Soup(html)
date = soup.find("div", {"class": "date"})
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
html = get("https://stocksng.com/category/business-economy/")
soup = Soup(html)
date = soup.find("div", {"class": "date"})
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}")
except Exception as e:
print(f"Market news data not available now ! {e}")

0 comments on commit 0c15615

Please sign in to comment.