在Python请求中没有得到正确的响应

时间:2015-02-19 12:26:52

标签: python web-scraping python-requests

我想抓下以下链接的详细信息: https://tickets.fandango.com/transaction/ticketing/seatpicker/Default.aspx?tid=AABRE&t=10:15&best_availability=1&mid=165809&quantity=1&action=availability&sdate=02/19/2015&_=1424341652537

我通过以下代码尝试了这个:

url = 'https://tickets.fandango.com/transaction/ticketing/seatpicker/Default.aspx?tid=AABRE&t=23:00&best_availability=1&mid=165809&quantity=1&action=availability&sdate=02/19/2015&_=1424341767809'

import urllib2

import cookielib

cj = cookielib.CookieJar()

opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.open('http://www.fandango.com')

urllib2.install_opener(opener)
request = urllib2.Request(url)
headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
 'Accept-Encoding': 'gzip, deflate, sdch',
 'Accept-Language': 'en-US,en;q=0.8',
 'Cache-Control': 'no-cache',
 'Connection': 'keep-alive',
 'Cookie': 'ASP.NET_SessionId=gr1wo51ilfr0x4stsci1w0kj; zip=682005; searchvalue=682005; source=MobileWeb; devicefamily=webbrowser; cmp=; __utma=3215655.1038919597.1424247224.1424324501.1424341427.5; __utmb=3215655.3.10.1424341428; __utmc=3215655; __utmz=3215655.1424247226.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __CT_Data=gpv=38&apv_124_www12=38; WRUID=0; sat_ppv=28; s_fid=5D01D2878A2B6577-3326336F9959062E; satellite={"prevPage":"movie times | tlp | amc webster 12","linkPos":"Movie Showtimes","linkName":"11:00pm"}; PurchaseProcessGroup=28b54ac3240d4960; RedirectLocation=https%3A//tickets.fandango.com/transaction/ticketing/express/ticketboxoffice.aspx%3Fmid%3D165809%26tid%3DAABRE%26row_count%3D0%26date%3D2/19/2015; mbox=PC#1423833654296-758486.19_20#1425551254|session#1424341424394-687421#1424343514|check#true#1424341714; __utma=226919832.242031956.1423833685.1424326988.1424341639.8; __utmb=226919832.3.10.1424341639; __utmc=226919832; __utmz=226919832.1424341639.8.7.utmcsr=fandango.com|utmccn=(referral)|utmcmd=referral|utmcct=/amcwebster12_aabre/theaterpage; s_pers=%20s_vnum%3D1426425659081%2526vn%253D10%7C1426425659081%3B%20qpv_pagename%3Dpurchase%2520%257C%2520seat%2520picker%2520%257C%2520onepage%7C1424343455690%3B%20s_nr%3D1424341655705-Repeat%7C1426933655705%3B%20s_invisit%3Dtrue%7C1424343455716%3B%20s_dayslastvisit%3D1424341655724%7C1518949655724%3B%20s_dayslastvisit_s%3DLess%2520than%25201%2520day%7C1424343455724%3B; adops_master_kvs=; s_vi=[CS]v1|2A6EFD1B851D13A3-4000010460014AAF[CE]; s_sess=%20SC_LINKS%3D%3B%20s_cc%3Dtrue%3B%20s_sq%3D%3B%20s_ppv%3D-%252C27%252C27%252C354%3B; bandid=; NSC_30092_208.39.66.13_TTM443=ffffffff09985e9145525d5f4f58455e445a4a423661; CounterTimeLeft=0',
 'Host': 'tickets.fandango.com',
 'Pragma': 'no-cache',
 'Referer': 'https://tickets.fandango.com/transaction/ticketing/express/SeatPicker.aspx',
 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36'}
for i,j in headers.iteritems():
    request.add_header(i,j)

requestData = urllib2.urlopen(request)
print requestData.read()

响应将在json中

{"request":{"action":"availability","tid":"AABRE","mid":"165809","sdate":"2/19/2015","t":"23:00","quantity":"1","best_availability":"1"},"response":{"status":{"code":2,"message":"One or more of the required parameters have values not matching with current order context. Required parameters are tid, mid, sdate, t and quantity"},"auditorium_physical_layout_url":"https://tickets.fandango.com/seatpicker/svg/","seat_picking_policy":0,"manifest":{"areas":[{"name":"default","selected":"True","AreaType":"Reserved","seats":[]}]},"reservation_time":{"end_time_gmt":"01/01/0001 00:00:00","duration":"0"},"show_time_page_url":"http://tickets.fandango.com/amcwebster12_aabre/theaterpage?rds=2&date=2/19/2015"}}

但我没有得到任何正确答案..

0 个答案:

没有答案