abdullahtarawneh.com/content/code/salatime/index.md

30 lines
1 KiB
Markdown
Raw Normal View History

2020-10-25 05:15:18 +00:00
---
title: "salatime"
summary: "Basic terminal script to print out daily prayer times for Birmingham, AL."
date: "2019-05-09"
2020-10-26 05:51:15 +00:00
author: "Abdullah Tarawneh"
2020-10-25 05:15:18 +00:00
tags: ["python", "web scraping", "scraping", "beautifulsoup", "salat", "prayer", "time"]
2020-10-26 06:29:04 +00:00
category: "Code"
2020-10-25 05:15:18 +00:00
cover: "/images/salatime.jpg"
---
## The problem
While working in a terminal environment, I would like to know what the current active prayer is, how much time I have left to pray, time to next prayer, and other such information.
## The research
The Birmingham Islamic Society provides tables of prayer times by month. This table can be scraped with Python Requests, then parsed with BeautifulSoup.
## The solution
Source code is available at https://github.com/trwnh/salatime
Pseudocode is as follows:
1. Get the current month, day, hour, and minute.
2. Get the page for the current month.
3. Get the times table out of this page.
4. Parse this table for a list of prayer times.
5. Parse this list for the current day's prayer times.
6. Calculate and print information.