#!/bin/python3 # Script to scrape the event listings webpage for the Róisín Dubh pub in Galway and generate an RSS feed # The page does appear to offer an RSS feed but it's broken and returns dates in the far future and distant past import requests from datetime import datetime listings = requests.get('https://roisindubh.net/remote/searchlistings.json').json()['results'] # using several print statements to prioritise code readability over efficiency (I/O speeds are unimportant to me) print('') print('Roisín Dubh Listingshttps://roisindubh.net/listings/') for listing in listings: if datetime.strptime(listing['event_date_time'], '%Y-%m-%dT%H:%M:%S') < datetime.now(): continue print('') print('' + listing['pagetitle'] + '') print('https://roisindubh.net/listings/' + listing['alias'] + '') print(' ') print('Ticket Allocation: ' + listing['ticket_allocation'] + '
') print('Tickets remaining?: ' + str(listing['ticket_remaining'] == '1') + '
') print('Event start time: ' + listing['event_date_time'] + '
') print('Late night?: ' + str(listing['late_night'] == '1') + '
') print('Postponed?: ' + str(listing['postponed'] == '1') + '
') print('Sales start time: ' + listing['sales_start'] + '
') print('On Sale?: ' + str(listing['on_sale'] == '1') + '
') print('Tickets remaining?: ' + str(listing['ticket_remaining'] == '1') + '
') if listing['external_ticket_url']: print('External Ticket URL: ' + listing['external_ticket_url'] + '') # unparsed json object: # "prices": { # "regular": 10, # "student": 0, # "vip": 0, # "ticket_limit": 10, # "ticket_limit_per_transaction": 1, # "discount": [] # }, print(']]>
') print('' + datetime.strptime(listing['event_date_time'], '%Y-%m-%dT%H:%M:%S').strftime('%a, %d %b %Y %H:%M:%S %z') + '') print('
') print('
')