Created
June 19, 2017 16:26
-
-
Save efaisal/da5e4e8b9b4726f1ef4879a9d64313cd to your computer and use it in GitHub Desktop.
Extract solat time from JAKIM
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
#!/usr/bin/env python | |
import sys | |
from urllib.request import urlopen | |
from bs4 import BeautifulSoup | |
URL = 'http://www2.e-solat.gov.my/xml/today/?zon=SGR01' | |
with urlopen(URL) as req: | |
if req.getcode() == 200: | |
soup = BeautifulSoup(req.read(), 'lxml') | |
else: | |
print('{} - {}'.format(req.getcode(), req.msg)) | |
sys.exit(1) | |
data = {item.title.text: item.description.text for item in soup.find_all('item')} | |
for k, v in data.items(): | |
print('{:<7} {}'.format(k, v)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment