Skip to content

Instantly share code, notes, and snippets.

@sphinxid
Created May 10, 2020 13:07
Show Gist options
  • Save sphinxid/dae31a6cbec2856fec1ffcb2a7cc4a7e to your computer and use it in GitHub Desktop.
Save sphinxid/dae31a6cbec2856fec1ffcb2a7cc4a7e to your computer and use it in GitHub Desktop.
Parse data dari kawalcorona.com tanpa API
## 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