Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daily Prayer Time #22

Open
abdulrcs opened this issue Apr 16, 2024 · 0 comments
Open

Daily Prayer Time #22

abdulrcs opened this issue Apr 16, 2024 · 0 comments

Comments

@abdulrcs
Copy link
Owner

abdulrcs commented Apr 16, 2024


slug: daily-prayer-time
date: 17-Jan-2021
summary: An easy-to-use API to get today’s prayer time based on Muslim Pro
techStack: Python, Flask
category: Personal Project
githubLink: https://github.com/abdulrcs/Daily-Prayer-Time-API
image: https://github.com/abdulrcs/abdulrahman.id/assets/54136956/4d46f56d-ed51-46c5-9b4f-1b110968935e

Overview

It's an easy-to-use API to get today's (and tomorrow!) prayer time for your next project! (based on Muslim Pro)

Project Goals

This API was actually written because of my personal use case, it was holiday season at the time and I wanted to maximize those online gaming sessions with my friends, we all know online games (like Valorant) can't be paused mid-match, so I built an API for my personal Discord bot to know how much session we can play before the next prayer time.

But I published the API for general use cases for many people by providing a smooth way to integrate prayer times into their projects 🎉

Tech Stack

Written in Python using Flask, Beautiful Soup, and duckduckgo_search.

Features ✨

API Response

{
  "city": "Mecca",
  "date": "25 March 2021",
  "today": {
    "Fajr": "05:04",
    "Sunrise": "06:20",
    "Dhuhr": "12:27",
    "Asr": "15:52",
    "Maghrib": "18:34",
    "Isha'a": "20:04"
  },
  "tomorrow": {
    "Date": "Fri 26 Mar",
    "Fajr": "05:03",
    "Sunrise": "06:19",
    "Dhuhr": "12:27",
    "Asr": "15:52",
    "Maghrib": "18:34",
    "Isha'a": "20:04"
  }
}

Challenges

There's a lot of complexities when you're doing web scraping.

My initial approach involved querying the Muslim Pro website directly for prayer times in various cities. However, this is ineffective because the URLs of the prayer time from each city are different and may involve the language of that city in the URL.

To address that issue, I had an idea of using a search engine, I can get the most relevant site by querying (city) prayer time site:muslimpro.com I can safely query any city in the world while making sure it's a valid Muslim Pro URL that way.

Then, the most inevitable problem of web scraping is the changes in the source website, Muslim Pro site has several HTML structure revisions, and I have to adjust and even rewrite the code at times.

Learning and Takeaways

This project turned out to be a win-win, because not only did I get to hone my coding skills by learning web scraping with Python, but I also created something that can be useful for others, the numerous thank-you notes to my email regarding this project were truly heartwarming.

It was the first time something I coded actually got used by other people, I still remember the first email I got and it really made my day :')

@abdulrcs abdulrcs changed the title Daily Prayer Time Daily Prayer Time API Apr 16, 2024
@abdulrcs abdulrcs changed the title Daily Prayer Time API Daily Prayer Time Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant