Created
August 26, 2016 13:48
-
-
Save logston/6ded65ad67351b99c46a5284a34f4092 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import json | |
import time | |
import requests | |
import pprint | |
headers = """ | |
Host: www.ticketmaster.com | |
Connection: keep-alive | |
Pragma: no-cache | |
Cache-Control: no-cache | |
Accept: text/javascript, text/html, application/xml, text/xml, */* | |
X-Prototype-Version: 1.7 | |
X-Requested-With: XMLHttpRequest | |
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 | |
Referer: http://www.ticketmaster.com/Richard-Rodgers-Theatre-tickets-New-York/venue/24592 | |
Accept-Encoding: gzip, deflate, sdch | |
Accept-Language: en-US,en;q=0.8,es;q=0.6 | |
""" | |
headers = headers.strip().split('\n') | |
headers = dict(tuple(v.strip() for v in h.split(':', 1)) for h in headers) | |
stub = 'http://www.ticketmaster.com/json/resale?command=get_resale_listings&event_id={}&location=RLP&ps=50&pn=1&mp=&mmp=&qty=2&sname=&sn=&so=&si=&iss=1&vfs=0&rsf=1&fbp=1' | |
session = requests.Session() | |
resp = session.get('http://www.ticketmaster.com/json/search/event?vid=24592', headers=headers) | |
content = resp.content.decode() | |
events = json.loads(content) | |
docs = events['response']['docs'] | |
event_ids = [d.get('EventId') for d in docs] | |
results = [] | |
for eid in event_ids: | |
print(eid) | |
resp = session.get(stub.format(eid), headers=headers) | |
content = resp.content.decode() | |
content = json.loads(content) | |
listings = content['listings'] | |
for listing in listings: | |
results.append((listing['price'], eid)) | |
time.sleep(1) | |
pprint.pprint(sorted(results)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment