Python crawler hyperlinks url containing Chinese error and solutions
python3.5 crawler error:
UnicodeEncodeError: 'ascii' codec can't encode characters
This error is caused by hyperlinks containing Chinese, hyperlinks are encoded in ascii by default, so they cannot appear directly in Chinese, if they want to appear in Chinese.
The solution is as follows:
import urllib from import urlopen link="/?cat=9987,653,655&ev=exbrand%5F9420&trans=1&JL=3_branding_GOLDEN LEAF(Gionee)" # Hyperlinks containing Chinese characters # Need to be converted link=(link) html=urlopen(link).read() # It's accessible, it doesn't report exceptions
The above is Python crawler error solution details, if you have any questions, please leave a message or to the site's community exchange and discussion, thank you for reading, I hope to help you, thank you for your support of this site!