-
-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathstatik_corona.py
More file actions
26 lines (19 loc) · 783 Bytes
/
statik_corona.py
File metadata and controls
26 lines (19 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# menampilkan informasi dari corona
import requests
from bs4 import BeautifulSoup
def status_covid(url: str = "https://www.worldometers.info/coronavirus") -> dict:
"""
menampilkan informasi covid 19 statistiknya
"""
soup = BeautifulSoup(requests.get(url).text, "html.parser")
find_data = soup.findAll("h1")
values = soup.findAll("div", {"class": "maincounter-number"})
find_data += soup.findAll("span", {"class": "panel-title"})
values += soup.findAll("div", {"class": "number-table-main"})
return {
key.text.strip(): value.text.strip() for key, value in zip(find_data, values)
}
if __name__ == "__main__":
print("status corona")
for find_data, values in status_covid().items():
print(f"{find_data} : {values}")