Beispiel #1
0
class PtCurlTest(unittest.TestCase):
    ##初始化工作  
    def setUp(self):  
        self.curl = PtCurl()  
        
    def tearDown(self):
        pass
    
    def test_get(self):
        url= "http://www.baidu.com"        
        res = self.curl.get(url)
        self.assertEqual(True, res.find("baidu") > 0, "")
        
    def test_post(self):
        url= "http://www.baidu.com"
        res = self.curl.post(url,"test=1")        
        self.assertEqual(True, res.find("baiduerr") > 0, "")
        
    def _test_request(self):
        url= "http://www.baidu.com"        
        res = self.curl.request('GET',url)
        self.assertEqual(True, res.find("baidu") > 0, "")
        res = self.curl.request('POST',url,"test=1")
        self.assertEqual(True, res.find("baiduerr") > 0, "")        
Beispiel #2
0
 def setUp(self):  
     self.curl = PtCurl()  
Beispiel #3
0
Datei: k8.py Projekt: ptphp/PtPy
from ptpy import PtCurl
import urllib
import pprint
import json

url = "http://www.kanairlines.com/ebooking/index.php?c=service&m=execute&ctl=flight-booking"

curl = PtCurl(debug = True,proxy = "127.0.0.1:8888")

query = {
         "xaction":"readDepart",
         "rows":'{"departDate":"27/04/2014","routeFrom":"CNX","routeTo":"NNT","seat":1}'
         }

data = urllib.urlencode(query)
res = curl.post(url, data)

print res
pprint.pprint(json.loads(res))
Beispiel #4
0
Datei: qg.py Projekt: ptphp/PtPy
from ptpy import PtCurl
import urllib
import pprint
import pycurl
import json

url = "http://book.citilink.co.id/Search.aspx"

curl = PtCurl(debug = False,proxy = "127.0.0.1:8888")

data = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUBMGRkBsrCYiDYbQKCOcoq%2FUTudEf14vk%3D&pageToken=&AvailabilitySearchInputSearchVieworiginStation1=LOP&AvailabilitySearchInputSearchView%24TextBoxMarketOrigin1=LOP&AvailabilitySearchInputSearchViewdestinationStation1=SUB&AvailabilitySearchInputSearchView%24TextBoxMarketDestination1=SUB&AvailabilitySearchInputSearchVieworiginStation2=&AvailabilitySearchInputSearchView%24TextBoxMarketOrigin2=&AvailabilitySearchInputSearchViewdestinationStation2=&AvailabilitySearchInputSearchView%24TextBoxMarketDestination2=&AvailabilitySearchInputSearchView%24DropDownListMarketDay1=11&AvailabilitySearchInputSearchView%24DropDownListMarketMonth1=2014-9&date_picker=2014-9-20&AvailabilitySearchInputSearchView%24DropDownListMarketDay2=07&AvailabilitySearchInputSearchView%24DropDownListMarketMonth2=2014-9&date_picker=2014-9-20&AvailabilitySearchInputSearchView%24RadioButtonMarketStructure=OneWay&AvailabilitySearchInputSearchView%24DropDownListPassengerType_ADT=1&AvailabilitySearchInputSearchView%24DropDownListPassengerType_CHD=0&AvailabilitySearchInputSearchView%24DropDownListPassengerType_INFANT=0&AvailabilitySearchInputSearchView%24DropDownListSearchBy=columnView&AvailabilitySearchInputSearchView%24ButtonSubmit=Find+Flights"
res = curl.post(url, data,{
    pycurl.FOLLOWLOCATION:1
})
print curl.EFFECTIVE_URL
res = curl.get("http://book.citilink.co.id/ScheduleSelect.aspx")
print res
Beispiel #5
0
from ptpy import PtCurl
import json
curl = PtCurl(debug=True,proxy="127.0.0.1:8888")
APPID = "wxa19b2bb098f2de68"
APPSECRET = "3c75f718d59de9403672304d8b0d94ff"
url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+APPID+"&secret="+APPSECRET

res = curl.get(url)
access_token = json.loads(res)['access_token']
print access_token