urlopen error unknown url type: http或 HTTP Error 400: Bad Request

DevTools listening on ws://127.0.0.1:18388/devtools/browser/166d68b9-5bd6-4eaf-9c9c-90b26921a7ae
Traceback (most recent call last):
  File "C:\Users\yanghang\Desktop\comic.py", line 39, in 
    urllib.request.urlretrieve(**thisurl2**,filename=localpath)
  File "F:\Python\lib\urllib\request.py", line 248, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "F:\Python\lib\urllib\request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "F:\Python\lib\urllib\request.py", line 526, in open
    response = self._open(req, data)
  File "F:\Python\lib\urllib\request.py", line 549, in _open
    'unknown_open', req)
  File "F:\Python\lib\urllib\request.py", line 504, in _call_chain
    result = func(*args)
  File "F:\Python\lib\urllib\request.py", line 1388, in unknown_open
    raise URLError('unknown url type: %s' % type)
urllib.error.URLError:  urlopen error unknown url type: "http

针对这个问题,我试过网上的很多方法都不行。但是我发现直接把thisurl2换成一个确定的url却不会报错,所以最简单的方法就是先把爬到的所有url放到一个list里,然后再调用

你可能感兴趣的:(urlopen error unknown url type: http或 HTTP Error 400: Bad Request)