0
我想使用yts api,並且我寫了下面的代碼。Urllib2不工作,http禁止的錯誤
import urllib2
import json
url = 'https://yts.ag/api/v2/list_movies.json?quality=3D'
json_obj = urllib2.urlopen(url)
data = json.load(json_obj)
print data
但我遇到了以下錯誤:
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py", line 435, in open
response = meth(req, response)
File "C:\Python27\lib\urllib2.py", line 548, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python27\lib\urllib2.py", line 473, in error
return self._call_chain(*args)
File "C:\Python27\lib\urllib2.py", line 407, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 556, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden
幫助我如何解決這個
可能重複:http://stackoverflow.com/questions/13303449/urllib2-httperror-http-error-403-forbidden – UnholySheep