SwVitaliy

Untitled

Apr 16th, 2012
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. import sys
  4. from grab import Grab
  5. import urllib
  6.  
  7.  
  8. g = Grab(reuse_cookies = True, reuse_referer=True)
  9.  
  10. g.setup(post={
  11.  
  12. 'EntryPoint': 'Flight',
  13. 'RequestFrom': 'Outside',
  14. 'TripType': 'rdbRoundTrip',
  15. 'WebSiteId': '189',
  16. 'arrival_label': 'bom',
  17. 'btnSubmitAir': 'Search for flights',
  18. 'ddlCabin': 'Y',
  19. 'ddlPaxADT': '1',
  20. 'ddlPaxCHD': '0',
  21. 'ddlPaxINF': '0',
  22. 'departure_label': 'syd',
  23. 'flight_search_action': 'http://res.webjet.com/process.aspx',
  24. 'txtArrCity1': 'bom',
  25. 'txtArrCity2': 'syd',
  26. 'txtDepCity1': 'syd',
  27. 'txtDepCity2': 'bom',
  28. 'txtdate1':urllib.quote('05/17/2012', ''),
  29. 'txtdate2':urllib.quote('05/27/2012', ''),
  30.  
  31. })
  32.  
  33. g.setup(user_agent="User-Agent Mozilla/5.0 (Ubuntu; X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0")
  34. g.go("http://res.webjet.com/process.aspx?agentid=189&"
  35. "txtDepCity1=syd&txtArrCity1=bom&TripType=rdbRoundTrip&txtDate1=" + urllib.quote('05/17/2012', '') + "&txtDate2=" + urllib.quote('05/27/2012', '') + "&"
  36. "txtDepCity2=bom&txtArrCity2=syd&ddlPaxADT=1&ddlPaxCHD=0&ddlPaxINF=0")
  37.  
  38. if not g.response.cookies.get("ASP.NET_SessionId", False):
  39. print "not auth"
  40. sys.exit(0)
  41.  
  42. g.setup(referer = "http://www.webjet.com/flights/")
  43.  
  44. loc = g.response.headers.get('Location', False)
  45. # print g.request_headers["Cookie"]
  46.  
  47. id1 = loc[loc.rindex('=')+1:]
  48.  
  49. g.setup(user_agent="User-Agent Mozilla/5.0 (Ubuntu; X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0")
  50. g.go("http://res.webjet.com" + loc)
  51. # print g.response.body
  52.  
  53. g.setup(user_agent="User-Agent Mozilla/5.0 (Ubuntu; X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0")
  54. g.go("http://res.webjet.com/prices.aspx?page=flightprices&air=Air&id1=" + urllib.quote(id1, ''))
  55.  
  56.  
  57. print g.response.body
Advertisement
Add Comment
Please, Sign In to add comment