接口測試-py-get

py-get請求實現方式

定義接口地址

定義請求數據

整理請求數據

發送數據並獲取結果

# -*-coding:utf8 -*-

import urllib

import urllib2

url ="http://reg.haibian.com/login/ajax_login"

#定義請求數據,並且對數據進行賦值

data={}

data['loginname']='[email protected]'

data['password']='111111'

#對請求數據進行編碼

data=urllib.urlencode(data)

#將數據和URL進行連接

request=url+'?'+data

#打開請求,獲取對象

requestResponse=urllib2.urlopen(request)

#讀取服務端返回的數據

ResponseStr=requestResponse.read()

#打印數據

ResponseStr=ResponStr.decode("unicode_escape")

print(ResponseStr)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章