awacke1 commited on
Commit
b4e1b44
·
1 Parent(s): 583eba3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -14
app.py CHANGED
@@ -2,19 +2,18 @@ import requests
2
  from bs4 import BeautifulSoup
3
  import streamlit as st
4
 
5
- # Define the URL of the Wikipedia page to scrape
6
- url = 'https://en.wikipedia.org/wiki/Health_care'
 
 
 
7
 
8
- # Send an HTTP request to the URL and get the HTML response
9
- response = requests.get(url)
 
 
 
 
10
 
11
- # Parse the HTML content using Beautiful Soup
12
- soup = BeautifulSoup(response.content, 'html.parser')
13
-
14
- # Find the list of articles on the page
15
- articles_list = soup.find('div', {'class': 'div-col columns column-width'}).find_all('li')
16
-
17
- # Display the list of articles in Streamlit
18
- st.write("List of articles on health care:")
19
- for article in articles_list:
20
- st.write(article.text)
 
2
  from bs4 import BeautifulSoup
3
  import streamlit as st
4
 
5
+ def scrape_wikipedia(url):
6
+ response = requests.get(url)
7
+ soup = BeautifulSoup(response.content, 'html.parser')
8
+ articles_list = soup.find('div', {'class': 'div-col columns column-width'}).find_all('li')
9
+ return articles_list
10
 
11
+ def main():
12
+ url = 'https://en.wikipedia.org/wiki/Health_care'
13
+ articles_list = scrape_wikipedia(url)
14
+ st.write("List of articles on health care:")
15
+ for article in articles_list:
16
+ st.write(article.text)
17
 
18
+ if __name__ == '__main__':
19
+ main()