Skip to content

Instantly share code, notes, and snippets.

@eladc
Last active June 1, 2019 15:20
Show Gist options
  • Save eladc/6312ffd08da007517099816916ea8228 to your computer and use it in GitHub Desktop.
Save eladc/6312ffd08da007517099816916ea8228 to your computer and use it in GitHub Desktop.
POST to a url - pass the response to a telegram bot
import requests as req
import json
def telegram_bot_sendtext(bot_message):
bot_token = ''
bot_chatID = ''
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + bot_message
response = req.post(send_text)
return response.json()
url = ''
params = {'action': 'get_lines', 'data[macabi_id]': '10', 'data[service_type]': 'hygenist', 'data[age]': 'A', 'paged': '1', 'getnearby': 'false', 'updateminicalander': 'true' , 'specificdate': '' ,'bday': '1'}
r = req.post(url, data=params)
x = json.loads(r.text)
mainkey = list(x['lines'].keys())
times = list(x['lines'][mainkey[0]].keys())
for t in times:
mon = x['lines'][mainkey[0]][t]['month']
day = x['lines'][mainkey[0]][t]['day']
msg = f'{day}-{mon} @ {t}'
telegram_bot_sendtext('{} is open'.format(msg))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment