Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import sys
- from grab import Grab
- import urllib
- g = Grab(reuse_cookies = True, reuse_referer=True)
- g.setup(post={
- 'EntryPoint': 'Flight',
- 'RequestFrom': 'Outside',
- 'TripType': 'rdbRoundTrip',
- 'WebSiteId': '189',
- 'arrival_label': 'bom',
- 'btnSubmitAir': 'Search for flights',
- 'ddlCabin': 'Y',
- 'ddlPaxADT': '1',
- 'ddlPaxCHD': '0',
- 'ddlPaxINF': '0',
- 'departure_label': 'syd',
- 'flight_search_action': 'http://res.webjet.com/process.aspx',
- 'txtArrCity1': 'bom',
- 'txtArrCity2': 'syd',
- 'txtDepCity1': 'syd',
- 'txtDepCity2': 'bom',
- 'txtdate1':urllib.quote('05/17/2012', ''),
- 'txtdate2':urllib.quote('05/27/2012', ''),
- })
- g.setup(user_agent="User-Agent Mozilla/5.0 (Ubuntu; X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0")
- g.go("http://res.webjet.com/process.aspx?agentid=189&"
- "txtDepCity1=syd&txtArrCity1=bom&TripType=rdbRoundTrip&txtDate1=" + urllib.quote('05/17/2012', '') + "&txtDate2=" + urllib.quote('05/27/2012', '') + "&"
- "txtDepCity2=bom&txtArrCity2=syd&ddlPaxADT=1&ddlPaxCHD=0&ddlPaxINF=0")
- if not g.response.cookies.get("ASP.NET_SessionId", False):
- print "not auth"
- sys.exit(0)
- g.setup(referer = "http://www.webjet.com/flights/")
- loc = g.response.headers.get('Location', False)
- # print g.request_headers["Cookie"]
- id1 = loc[loc.rindex('=')+1:]
- g.setup(user_agent="User-Agent Mozilla/5.0 (Ubuntu; X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0")
- g.go("http://res.webjet.com" + loc)
- # print g.response.body
- g.setup(user_agent="User-Agent Mozilla/5.0 (Ubuntu; X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0")
- g.go("http://res.webjet.com/prices.aspx?page=flightprices&air=Air&id1=" + urllib.quote(id1, ''))
- print g.response.body
Advertisement
Add Comment
Please, Sign In to add comment