1
我已經安裝https://github.com/muhuk/python-awis以從alexa獲取URL信息。Python Awis API不提供IOError
我用這
import awis
api = AwisApi(ACCESS_ID, SECRET_ACCESS_KEY)
tree = api.url_info(("example1.com", "example2.com", "example3.com"), "Rank", "LinksInCount")
elem = tree.find("//{%s}StatusCode" % api.NS_PREFIXES["alexa"])
assert eenter code herelem.text == "Success"
當我嘗試運行該腳本,我得到這個錯誤:
Traceback (most recent call last):
File "C:\Users\John\Desktop\Python Scripts\Domains\alexa api\AlexaURL.py", line 3, in <module>
tree = api.url_info(("example1.com", "example2.com", "example3.com"), "Rank", "LinksInCount")
File "C:\Users\John\Desktop\Python Scripts\Domains\alexa api\awis\__init__.py", line 121, in url_info
[Finished in 0.5s with exit code 1] return self.request(params, **kwargs)
File "C:\Users\John\Desktop\Python Scripts\Domains\alexa api\awis\__init__.py", line 91, in request
response = urllib.urlopen(url)
File "C:\python27\lib\urllib.py", line 87, in urlopen
return opener.open(url)
File "C:\python27\lib\urllib.py", line 208, in open
return getattr(self, name)(url)
File "C:\python27\lib\urllib.py", line 359, in open_http
return self.http_error(url, fp, errcode, errmsg, headers)
File "C:\python27\lib\urllib.py", line 372, in http_error
result = method(url, fp, errcode, errmsg, headers)
File "C:\python27\lib\urllib.py", line 683, in http_error_401
errcode, errmsg, headers)
File "C:\python27\lib\urllib.py", line 381, in http_error_default
raise IOError, ('http error', errcode, errmsg, headers)
IOError: ('http error', 401, 'Unauthorized', <httplib.HTTPMessage instance at 0x022FD580>)
任何想法?
謝謝我會試試這個。快速問題你是什麼意思,確保我將它們作爲字節傳遞,你有沒有例子? – mofoparrot
@mofoparrot我用你可以使用的代碼示例編輯答案。希望能幫助到你。 –
@NikosSteiakakis我不斷收到此響應IOError:所有3個請求失敗,最新的響應代碼是403 – ashim888