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

41 lines
1.7 KiB
Markdown
Raw Normal View History

2024-03-14 23:29:33 +00:00
+++
title = "salatime"
2024-06-02 05:04:04 +00:00
summary = "[OBSOLETE] Basic terminal script to print out daily prayer times for Birmingham, AL."
date = 2019-05-09
2024-03-14 23:29:33 +00:00
author = "Abdullah Tarawneh"
tags = ["python", "web scraping", "scraping", "beautifulsoup", "salat", "prayer", "time"]
categories = ["Code"]
2024-06-02 05:04:04 +00:00
aliases = [
"/code/salatime",
]
2024-03-14 23:29:33 +00:00
+++
2020-10-25 05:15:18 +00:00
2024-03-17 23:19:37 +00:00
<aside style="background: #ffcccc; padding: 1em; border-left: 4px solid red;">
<p style="font-weight: bold; display: flex; align-items: center; gap: 0.5em;">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-5 h-5" width=20 height=20>
<path fill-rule="evenodd" d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16ZM8.28 7.22a.75.75 0 0 0-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 1 0 1.06 1.06L10 11.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L11.06 10l1.72-1.72a.75.75 0 0 0-1.06-1.06L10 8.94 8.28 7.22Z" clip-rule="evenodd" />
</svg>
This no longer works.</p>
<p>The web service that was providing the source data is now unavailable.</p>
</aside>
2020-10-25 05:15:18 +00:00
## 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.