1.
urllib.urlencode(params)
replace with
urllib.parse.urlencode(params)
2.
After python3.3, urllib2 can no longer be used, and can only be replaced by urllib.request
response=urllib2.urlopen('
Change urllib2 to urllib.request to run normally
File "b.py", line 1, in <module>
ImportError: No module named 'urllib2'
Change urllib2 to urllib.request to run normally
import urllib.request
print(urllib.request.__file__)
3.
When learning crawlers, I encountered a problem when using postdata:
POST data should be bytes or an iterable of bytes
At first, I thought that there was a problem with my own code, but after comparing the tutorial and my own code, there was no error.
I checked on the Internet and I can use the following statement to solve it.
data = urllib.parse.urlencode(values).encode(encoding='UTF8')