Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,19 +2,18 @@ import requests
|
|
2 |
from bs4 import BeautifulSoup
|
3 |
import streamlit as st
|
4 |
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|