I'm using this code below to retrieve information from the Alexa API, this code works well on Python 2.7 but I have to use Python 2.6 and it gives me an error:
findall() takes exactly 2 arguments (3 given)
I presume that this method has change in Python 2.7 but I don't know how to make it work in 2.6.
NS_PREFIXES = {
"alexa": "http://alexa.amazonaws.com/doc/2005-10-05/",
"awis": "http://awis.amazonaws.com/doc/2005-07-11",
}
tree = api.sites_linking_in(domain + ".eu", count=10, start=0)
alexa_sites_linkin_in = {}
for element in tree.findall('//awis:SitesLinkingIn/awis:Site',NS_PREFIXES):
alexa_sites_linkin_in.update({
element.find('awis:Title', NS_PREFIXES).text: element.find('awis:Url', "awis").text})
The api used
lxml
(ElementTree as backport) for parsing xml. Thelxml
allowed additional argument - namespace, but ElementTree does not allow. That is problem. So as hotfix I recommend install lxml.