コード例 #1
0
ファイル: test.py プロジェクト: ptphp/PtPy
 def on_get_cookie(self):
     man = self.browser.page.networkAccessManager()
   
     element = self.main_frame.findFirstElement("#searchForm")
     url = "http://www.singaporeair.com"+element.attribute("action")
     
     #request = QNetworkRequest()
     #request.setUrl(QUrl(url))
     #request.setRawHeader("User-Agent", "MyOwnBrowser 1.0")
     #request.setRawHeader("Content-Type", "application/x-www-form-urlencoded")
     #reply = man.post(request,"fromHomePage=true&_payByMiles=on&_pwmFlightSearchCheckBox=on&recentSearches=&origin=PEK&destination=BKK&departureDay=23&departureMonth=042014&_tripType=on&returnDay=23&returnMonth=052014&cabinClass=Y&numOfAdults=1&numOfChildren=0&numOfInfants=0&_eventId_flightSearchEvent=&isLoggedInUser=false&numOfChildNominees=&numOfAdultNominees=")
     #reply.finished.connect(self.__on_reply_finished)
     #self.reply = reply
     curl = PtCurl(debug = True,proxy="127.0.0.1:8888")
     data = "fromHomePage=true&_payByMiles=on&_pwmFlightSearchCheckBox=on&recentSearches=&origin=PEK&destination=BKK&departureDay=23&departureMonth=042014&_tripType=on&returnDay=23&returnMonth=052014&cabinClass=Y&numOfAdults=1&numOfChildren=0&numOfInfants=0&_eventId_flightSearchEvent=&isLoggedInUser=false&numOfChildNominees=&numOfAdultNominees="
     
     cookies =[]
     for c in man.cookieJar().allCookies():
         cookies.append(str(c.name())+"="+str(c.value()))
     print self.main_frame.url().toString()
     res = curl.post(url, data,{
                                     pycurl.HTTPHEADER:[
                                                        "Content-Type: application/x-www-form-urlencoded"
                                                        ],
                                     pycurl.COOKIE:";".join(cookies),
                                     pycurl.REFERER:self.main_frame.url().toString(),
                                     pycurl.FOLLOWLOCATION:0
                                     })
     curl.get("http://www.singaporeair.com/booking-flow.form")
コード例 #2
0
ファイル: malindoair.py プロジェクト: ptphp/PtPy
    def test_open(self):
        curl = PtCurl(debug = True,proxy = "127.0.0.1:8888",cookie = "malindoair.txt" )
        res = curl.get("http://www.malindoair.com/en")
        
        url = "https://search.malindoair.com/default.aspx?aid=91&df=UK&edepCity=&earrCity=&culture=en-GB&afid=0&b2b=0&St=fa&hotelcode=&councode=&adult2=0&child2=0&infant2=0&DFlight=false&roomcount=1&currency=MYR&cpromo=&Jtype=1&depCity=DAC&arrCity=DPS&depDate=22%2F04%2F2014&adult1=1&child1=0&infant1=0&childage1r1=0&childage1r2=0&childage1r3=0&childage2r1=0&childage2r2=0&childage3r1=0&promocode="
        res = curl.get(url)

        m = re.search("window.location.href = '([^']+)';",res)
        url = "https://search.malindoair.com/" + m.group(1)
        res = curl.get(url)
                
        res = curl.post("https://search.malindoair.com/Flight.aspx/GetFlightSearch","{}",
                        {
                         pycurl.REFERER:url,
                         pycurl.HTTPHEADER:[
                            "Content-Type: application/json; charset=UTF-8",
                            "X-Requested-With: XMLHttpRequest",
                            ]
                         })
コード例 #3
0
ファイル: k6.py プロジェクト: ptphp/PtPy
 def test_open(self):
     
     origin = "BKK"
     destination = "REP"
     departureDate = "2014-04-21"
     url = "https://wl-prod.sabresonicweb.com/SSW2010/K6K6/webqtrip.html"
     
     postData = "alternativeLandingPage=true&lang=en&journeySpan=OW&"
     postData += "origin=" + origin + "&"
     postData += "destination=" + destination + "&"
     postData += "departureDate=" + departureDate + "&"
     postData += "numAdults=1&numChildren=0&numInfants=0"
             
     #return
     curl = PtCurl()
     curl.headers = [
                     "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36",
                     'Connection: keep-alive',
                     'Accept-Language: en-US,en;q=0.8',
                     'Accept-Encoding: gzip,deflate',
                     'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
                     "Content-Type:application/x-www-form-urlencoded"
                      ]
     
     res = curl.post(url, postData, {
                               pycurl.VERBOSE:1
                               })
     e_url = curl.EFFECTIVE_URL
     execution =  urlparse.urlparse(e_url).query.replace("execution=","")
     
     
     d_date = "2014/04/25 00:00:00"
     
     format="%Y/%m/%d %H:%M:%S"
     dt = datetime.datetime.strptime(d_date, format)
     refer_url = e_url;
     headers = curl.headers
     headers.append("Referer:https://wl-prod.sabresonicweb.com/SSW2010/K6K6/webqtrip.html?execution="+execution)
     headers.append("X-Requested-With:XMLHttpRequest")
     for i in range(30*6):
         print "*"*40
         time.sleep(1)        
         i = i + 1     
         t = (dt+datetime.timedelta(i)).strftime(format).strip() 
         url = "https://wl-prod.sabresonicweb.com/SSW2010/K6K6/webqtrip.html"
         data = '_eventId_ajax=&execution='+execution+'&ajaxSource=true&contextObject={"transferObjects":[{"componentType":"flc","actionCode":"dateChanged","queryData":{"componentId":"flc_1","componentType":"flc","actionCode":"dateChanged","queryData":null,"basketHashRefs":[null],"departureDate":"'+t+'","returnDate":null,"requestPartials":["__oneway"]}}]}'
         
         
         res = curl.post(url, data, {
                                   pycurl.VERBOSE:1,
                                   pycurl.HTTPHEADER:headers
                                   })
         print t
         if res:                
             res_ = json.loads(res.strip())
             outbounds = res_['content'][0]['model']['outbounds']
             for outbound in outbounds:
                 #pprint.pprint(outbound)
                 print "*"*20
                 print outbound["itineraryPartData"]['aircraftType']
                 print outbound["itineraryPartData"]['airlineCodes']
                 print outbound["itineraryPartData"]['departureCode']
                 print outbound["itineraryPartData"]['arrivalCodes']
                 print outbound["itineraryPartData"]['departureDate']
コード例 #4
0
ファイル: singaporeair.py プロジェクト: ptphp/PtPy
class SqParse():
    def __init__(self):
        self.curl = PtCurl()
        
    def get_execution(self,url = "http://www.singaporeair.com/SAA-flow.form?execution=e4s1"):
        return urlparse.urlparse(url).query.replace("execution=","")
    
    def open(self):     
        self.curl = PtCurl(debug = True,proxy = "127.0.0.1:8888",cookie = "singaporeair.txt" )
        url = "http://www.singaporeair.com/"    
        res = self.curl.get(url)          
        
        url = "http://www.singaporeair.com/SAA-flow.form"
        res = self.curl.get(url)            
        refer =  self.curl.EFFECTIVE_URL    
        self.curl.get("http://www.singaporeair.com/breakingAlert.form",
                      {
                       pycurl.HTTPHEADER:[
                                          "X-Requested-With: XMLHttpRequest"
                                          ]
                       }
                      )
        
        location =  self.curl.EFFECTIVE_URL
        r = {}
        r['r'] = refer
        r['s'] = str(time.time()).replace(".","")+"0"
        AKSB = urllib.urlencode(r)
        execution = self.get_execution_from_form(res)
        print execution
        #execution = self.get_execution(refer)
        #print execution
       
        url = "http://www.singaporeair.com/booking-flow.form?execution=" + execution.strip()
        origin = "PEK"
        dest = "BKK"
        d_month = "042014"
        d_day = "22"        
        r_month = "052014"
        r_day = "5"
        
        data = "_payByMiles=on&_pwmFlightSearchCheckBox=on&recentSearches=&origin=PVG&destination=BKK&departureDay=23&departureMonth=042014&_tripType=on&returnDay=14&returnMonth=052014&cabinClass=Y&numOfAdults=1&numOfChildren=0&numOfInfants=0&_eventId_flightSearchEvent=&isLoggedInUser=false&numOfChildNominees=&numOfAdultNominees="
        
        res = self.curl.post(url, data,{
                                        pycurl.HTTPHEADER:[
                                                           "Content-Type: application/x-www-form-urlencoded"
                                                           ],
                                        pycurl.REFERER:refer,
                                        pycurl.COOKIE:"AKSB="+AKSB
                                        })
        
        #location = self.curl.EFFECTIVE_URL
        
        #print len(res)
        
        #self.curl.get(location,{
        #                   pycurl.VERBOSE:2,
        #                   })
        
    def get_execution_from_form(self,form = '<form id="searchForm" class="jQvalidateForm" action="/booking-flow.form?execution=e1s1" method="post">'):
        m = re.search("id=\"searchForm\" class=\"jQvalidateForm\" action=\"/booking-flow.form\?execution=([^\"]+)",form)
        return m.group(1)