Skip to content

Instantly share code, notes, and snippets.

@efaisal
Created June 19, 2017 16:26
Show Gist options
  • Save efaisal/da5e4e8b9b4726f1ef4879a9d64313cd to your computer and use it in GitHub Desktop.
Save efaisal/da5e4e8b9b4726f1ef4879a9d64313cd to your computer and use it in GitHub Desktop.
Extract solat time from JAKIM
#!/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