Created
May 10, 2020 13:07
-
-
Save sphinxid/dae31a6cbec2856fec1ffcb2a7cc4a7e to your computer and use it in GitHub Desktop.
Parse data dari kawalcorona.com tanpa API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## python3 | |
from lxml import html | |
import requests | |
h = {'cookie': 'nocache'} | |
p = requests.get('https://kawalcorona.com/', headers=h) | |
c = p.text | |
x = html.document_fromstring(c) | |
data = x.xpath('//div[4]/div/div/div/div/p[1]/b') | |
positif = int(data[0].text_content().replace(',','')) | |
sembuh = int(data[1].text_content().replace(',','')) | |
meninggal = int(data[2].text_content().replace(',','')) | |
dirawat = int(positif - sembuh - meninggal) | |
print("positif = {}".format(positif)) | |
print("sembuh = {}".format(sembuh)) | |
print("meninggal = {}".format(meninggal)) | |
print("dirawat = {}".format(dirawat)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment