Spaces:
Sleeping
Sleeping
Neurolingua
commited on
Commit
•
d56ec24
1
Parent(s):
85cb515
Update other_function.py
Browse files- other_function.py +19 -0
other_function.py
CHANGED
@@ -140,3 +140,22 @@ def get_rates(): # URL to scrape
|
|
140 |
|
141 |
|
142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
|
141 |
|
142 |
|
143 |
+
def get_news():
|
144 |
+
news=[] # URL to scrape
|
145 |
+
url = "https://economictimes.indiatimes.com/news/economy/agriculture?from=mdr"
|
146 |
+
|
147 |
+
# Fetch the webpage content using ZenRows
|
148 |
+
response = client.get(url)
|
149 |
+
|
150 |
+
# Check if the request was successful
|
151 |
+
if response.status_code == 200:
|
152 |
+
# Parse the raw HTML content with BeautifulSoup
|
153 |
+
soup = BeautifulSoup(response.content, 'html.parser')
|
154 |
+
|
155 |
+
# Find the table rows containing the data
|
156 |
+
headlines = soup.find_all("div", class_="eachStory")
|
157 |
+
for story in headlines:
|
158 |
+
# Extract the headline
|
159 |
+
headline = story.find('h3').text.strip()
|
160 |
+
news.append(headline)
|
161 |
+
return news
|