Reason: the “httplib” module in Python 2. X becomes “http.Client” in Python 3. X
Original code:
import httplib
import urllib
reqheaders={
'MobileType':'Android',
'DeviceToken':'xxxxxxxxx',
'OSVersion':'1.0.3',
'AppVersion':'14',
'Host':'192.xxx.x.xxxx'}
reqconn=httplib.HTTPConnection("192.xxx.x.xxxx")
reqconn.request("GET", "/Login?username=1416&password=123", None, reqheaders)
res=reqconn.getresponse()
print res.status, res.reason
print res.msg
print res.read()
Modified code:
import http.client #Modify the referenced module
import urllib
reqheaders={
'MobileType':'Android',
'DeviceToken':'xxxxxxxxx',
'OSVersion':'1.0.3',
'AppVersion':'14',
'Host':'192.xxx.x.xxxx'}
reqconn=http.client.HTTPConnection("192.xxx.x.xxxx") #Modify the corresponding method
reqconn.request("GET", "/Login?username=1416&password=123", None, reqheaders)
res=reqconn.getresponse()
print (res.status, res.reason)
print (res.msg)
print (res.read())
Similar Posts:
- Differences of urllib, urllib2, httplib and httplib2 libraries in Python
- python3.7 pip install livetest Error [How to Solve]
- How to Solve Error: Heartbeating to master:7182 failed.
- [Solved] Git Clone Error: The requested URL returned error: 403 error
- [github] Push remote: Invalid username or password
- The unknown host problem of FTP IPv6 in zZW Linux
- An error is reported when logging into harbor warehouse with docker login of other hosts
- [Solved] HTTP Error 301: The HTTP server returned a redirect error that would lead to an infinite loop.
- [Solved] pymongo.errors.OperationFailure: Authentication failed.
- [Solved] Nginx 502Bad Gateway: some static resources cannot be accessed