# _*_ coding::utf_8 _*_ import urllib.request import urllib.parse post_url='http://192.168.255.195:8080/Control' form_data={ 'id': '2000', 'strAccount': '18765888179', 'strPassword': '123123', 'savePWD': '0' } headers={ # Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3 # Accept-Encoding: gzip, deflate # Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7 # Cache-Control: max-age=0 # Connection: keep-alive # Content-Length: 59 # Content-Type: application/x-www-form-urlencoded 'Cookie': 'JSESSIONID=285F98CD7C210C199FD11B3C10BDB935; smartdot=123123; myusername=18765888179; pwd=123123; username=18765888179', 'Host': '192.168.255.195:8080', 'Origin': 'http://192.168.255.195:8080', 'Referer': 'http://192.168.255.195:8080/Control?id=1000', 'Upgrade-Insecure-Requests':'1', 'User-Agent': '"Mozilla/5.0 (Linux; U; Android 2.2.1; zh-cn; HTC_Wildfire_A3333 Build/FRG83D) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1' } form_data=urllib.parse.urlencode(form_data).encode() # 伪装 url=urllib.request.Request(url=post_url,headers=headers) #post请求中要加入data值 response=urllib.request.urlopen(url,data=form_data) print(response.read().decode('gbk')) # response=urllib.request.urlopen(post_url).read() # print(response.decode('gb2312'))