PYTHON 3 crawler has the problem of

Python3 teaches by hand
Official Python Manual
The problem
When writing crawlers in Python, I encountered an error of Urlopen:

>>> url = """https://www.google.com.hk/search?newwindow=1&safe=strict&biw=960&bih=430&noj=1&q=django&oq=django
&gs_l=serp.3...664389.664389.0.664921.1.1.0.0.0.0.0.0..0.0....0...1c..64.serp
..1.0.0.cfHP0MSxtWU
"""
... ...
<urlopen error no host given>

There are many reasons for this problem. For example, in order to prevent program access, some websites need to add headers, etc., in order to access normally, otherwise this error will be reported.
The solution
In fact, careful friends will find me above the code for elegance, with “” “” “” to continue line, and with the return to the URL path to truncate. So here’s the problem — this is the same as introducing the ‘/n’ character into the original URL string, so the path is wrong, so it won’t open!
As long as you don’t press enter, you can resume the normal use of urllib.request-open.
(Question: But how do you achieve line wrapping in this case?Just use ‘a’ + ‘b’ + ‘c’ ~)

Read More: