Skip to content

Instantly share code, notes, and snippets.

@mrhalix
Created July 8, 2023 12:04
Show Gist options
  • Save mrhalix/9fe0a0680904f5c15e44d625a844f193 to your computer and use it in GitHub Desktop.
Save mrhalix/9fe0a0680904f5c15e44d625a844f193 to your computer and use it in GitHub Desktop.
Periodically check if you're in snappfood restaurant delivery area and receive notification on telegram whenever you are, crontab needed
import requests
import json
import time
headers = {
'authority': 'snappfood.ir',
'referer': 'https://snappfood.ir/search?query=%D9%86%D8%A7%D9%86%20%D8%B3%D8%AD%D8%B1&page=0',
'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
}
response = requests.get(
'https://snappfood.ir/search/api/v1/desktop/search?lat=59.764&long=67.421&query=%D9%86%D8%A7%D9%86+%D8%B3%D8%AD%D8%B1&superType=[undefined]&product_page_size=8&vendor_page_size=4&locale=fa',
headers=headers,
)
jdat = json.loads(response.text)
for vendor in jdat['data']['vendor']['items']:
if vendor['title'] == 'نان سحر (شریعتی)':
if vendor['deliver']:
for i in range(10):
requests.get("https://api.telegram.org/bot<<TOKEN>>/sendMessage?chat_id=293681227&text=Nan Sahar is open now")
time.sleep(5)
else:
print("Can't deliver")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment