Created
November 26, 2016 11:09
-
-
Save r3m0t/946fe543112be40ba183eb146f6d570b to your computer and use it in GitHub Desktop.
Resident Advisor watcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim: autoindent et ts=4 sw=4 ft=python | |
import requests | |
import lxml.html | |
import traceback | |
URL = 'https://www.residentadvisor.net/event.aspx?event_id' | |
SLACK_URL = 'https://hooks.slack.com/services/Twebhook_url_herek' | |
def ticket_available(url): | |
page = lxml.html.document_fromstring(requests.get(url).text) | |
try: | |
page.get_element_by_id('buynow') | |
except KeyError: return False | |
else: return True | |
def notify_ok(url): | |
return slack_say('Ticket available on <{}>'.format(url)) | |
def slack_say(message): | |
requests.post(SLACK_URL, | |
json={'text': message}) | |
if __name__ == '__main__': | |
try: | |
if ticket_available(URL): notify_ok(URL) | |
else: pass | |
except: | |
slack_say(traceback.format_exc()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lxml | |
requests |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment