sharsh02 commited on
Commit
e767ae0
1 Parent(s): 6d7afc2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
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
- stock_href.append(insight.find(class_='stock-name').find('a')['href'])
 
 
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