Python Awis API giving not IOError -


i have installed https://github.com/muhuk/python-awis in order url information alexa.

i using

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" 

when try run script, error:

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 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 @ 0x022fd580>) 

any ideas?

the response "401 unauthorized", means access_id and/or secret_access_key not correct.

also, make sure pass 2 aforementioned keys bytes , not strings, or error there well.

you can use str.encode function like:

 api = awis.awisapi(str.encode(self.access_key_id),                            str.encode(self.secret_access_key_id)) 

otherwise script correct. use , works.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -