ashim888 / awis

A python script to query Amazon's Alexa Web Information Service (AWIS).
GNU General Public License v3.0
37 stars 18 forks source link

KeyError with 'Response' from UrlInfo #8

Closed mikkokotila closed 6 years ago

mikkokotila commented 6 years ago

Following the example code on the README.md and using the git master, I'm getting the below error message.

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-3-9304a8f0e37b> in <module>()
----> 1 pprint.pprint(flatten_urlinfo(urlinfo))

/Users/mikko/dev/norway/lib/python2.7/site-packages/myawis/__init__.pyc in flatten_urlinfo(urlinfo, shorter_keys)
    161     _result = {}
    162     info = xmltodict.parse(str(urlinfo))
--> 163     flatten(info["aws:UrlInfoResponse"]["Response"]["UrlInfoResult"]["Alexa"])
    164     _result["OutputTimestamp"] = create_timestamp()
    165     return _result

KeyError: 'Response'
mikkokotila commented 6 years ago

This might have to do with the xml object I'm getting from calling the API. It looks like this:

<?xml version="1.0" encoding="unicode-escape"?>\n<aws:UrlInfoResponse xmlns:aws="http://alexa.amazonaws.com/doc/2005-10-05/"><aws:Response><aws:ResponseStatus><aws:StatusCode>InvalidResponseGroups</aws:StatusCode><aws:StatusMessage>The following response groups are invalid: UrlInfo</aws:StatusMessage></aws:ResponseStatus></aws:Response></aws:UrlInfoResponse>

If I'm trying any of the response groups from the docs, I'm not getting any other result than this. Could you include a couple of validated / working use examples on the README.md. Thanks!

NOTE: also 'History' you call in the bottom example does not work differently, it says also that the response group is invalid.

isaacbernat commented 6 years ago

Hi @mikkokotila, I will return on vacation late next week. If you have not found the issue, I'll take a look into this.

ashim888 commented 6 years ago

@mikkokotila just Implemented V4 signing process by @liehendi11 Please verify once.