은 내가이urllib2가의 HTTP 오류 400 : 잘못된 요청
host = 'http://www.bing.com/search?q=%s&go=&qs=n&sk=&sc=8-13&first=%s' % (query, page)
req = urllib2.Request(host)
req.add_header('User-Agent', User_Agent)
response = urllib2.urlopen(req)
과 같은 코드의 조각 때 "개"나는 다음과 같은 오류가 같은 I 입력 쿼리 더 이상의 단어가 있습니다.
response = urllib2.urlopen(req)
File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 400, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 513, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 438, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 372, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 521, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: Bad Request
어떤 사람이 잘못된 일을 지적 할 수 있습니까? 미리 감사드립니다.
공백이있는 URL을 요청할 때 "urllib2.HTTPError : HTTP 오류 406 : 사용할 수 없음"도 수신했습니다. – jamesc