Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ client = InferenceClient(
|
|
20 |
|
21 |
def todays_news():
|
22 |
url = 'https://trendlyne.com/markets-today/'
|
23 |
-
|
24 |
# Fetch the HTML content of the webpage
|
25 |
html_content = requests.get(url).text
|
26 |
soup = BeautifulSoup(html_content, 'html.parser')
|
@@ -38,11 +38,16 @@ def todays_news():
|
|
38 |
timestampo = timestamp.text.strip() if timestamp else timestampo
|
39 |
timestamps.append(timestampo)
|
40 |
stock_names.append(insight.find(class_='stock-name').text.strip())
|
41 |
-
|
|
|
|
|
42 |
insight_label.append(insight.find(class_='stock-insight-label').text.strip())
|
|
|
43 |
notification.append(insight.find(class_='insight-notification').text.strip())
|
|
|
44 |
|
45 |
df = pd.DataFrame({"Timestamp": timestamps, "Stock": stock_names, "Link": stock_href, "Label": insight_label, "Notification": notification})
|
|
|
46 |
df_dict = df.to_dict('records')
|
47 |
return df_dict
|
48 |
|
|
|
20 |
|
21 |
def todays_news():
|
22 |
url = 'https://trendlyne.com/markets-today/'
|
23 |
+
print("getting news from", url)
|
24 |
# Fetch the HTML content of the webpage
|
25 |
html_content = requests.get(url).text
|
26 |
soup = BeautifulSoup(html_content, 'html.parser')
|
|
|
38 |
timestampo = timestamp.text.strip() if timestamp else timestampo
|
39 |
timestamps.append(timestampo)
|
40 |
stock_names.append(insight.find(class_='stock-name').text.strip())
|
41 |
+
print("stock_name retrieved")
|
42 |
+
stock_href.append("https://trendlyne.com"+insight.find(class_='stock-name').find('a')['href'])
|
43 |
+
print("stock_link retrieved")
|
44 |
insight_label.append(insight.find(class_='stock-insight-label').text.strip())
|
45 |
+
print("stock_label retrieved")
|
46 |
notification.append(insight.find(class_='insight-notification').text.strip())
|
47 |
+
print("stock_notification retrieved")
|
48 |
|
49 |
df = pd.DataFrame({"Timestamp": timestamps, "Stock": stock_names, "Link": stock_href, "Label": insight_label, "Notification": notification})
|
50 |
+
print("Dataframe created for stocks in news today")
|
51 |
df_dict = df.to_dict('records')
|
52 |
return df_dict
|
53 |
|