Skip to content

Instantly share code, notes, and snippets.

@r3m0t
Created November 26, 2016 11:09
Show Gist options
  • Save r3m0t/946fe543112be40ba183eb146f6d570b to your computer and use it in GitHub Desktop.
Save r3m0t/946fe543112be40ba183eb146f6d570b to your computer and use it in GitHub Desktop.
Resident Advisor watcher
# 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())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment