Skip to content

Instantly share code, notes, and snippets.

@elmoiv
Created December 19, 2020 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elmoiv/64273118473177bbc8aea3bdce13befe to your computer and use it in GitHub Desktop.
Save elmoiv/64273118473177bbc8aea3bdce13befe to your computer and use it in GitHub Desktop.
Get Damietta Prayer Times
import requests
import re
from datetime import datetime
URL = 'https://prayertimes.me/Damietta.html'
PRAYERS = ['Fajr', 'Dhuhr', 'Asr', 'Maghrib', 'Isha']
def getPrayerTimes(page):
'''
Gets prayer times from prayertimes.me
'''
prayerTimes = re.findall(
'list-prayer\d*-item">(.*?)<span class'
'="badge badge-clockdif">(.*?)</span>',
page
)[1:]
# Join PRAYERS with times from page results
# And convert arabic to english
cleanPrayers = map(lambda d:f"{d[0]}: {d[1][1][1:].replace('ص','AM').replace('م', 'PM')}" , zip(PRAYERS, prayerTimes))
return cleanPrayers
print('Getting Prayer Times...\n')
data = requests.get(URL).content.decode()
print('DATE: ', str(datetime.now()).split(' ')[0], '\n')
print(*getPrayerTimes(data), sep='\n')
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment