Python-Alexa-Ergebnis, das mit lxml.etree analysiert wird
Ich benutze alexa api von aws, aber ich finde es schwierig, das Ergebnis zu analysieren, um das zu bekommen, was ich will
alexa api gibt einen Objektbaum zurück<type 'lxml.etree._ElementTree'>
Ich benutze diesen Code, um den Baum zu drucken
from lxml import etree
root = tree.getroot()
print etree.tostring(root)
Ich bekomme XML unten
<aws:UrlInfoResponse xmlns:aws="http://alexa.amazonaws.com/doc/2005-10-05/"><aws:Response xmlns:aws="http://awis.amazonaws.com/doc/2005-07-11"><aws:OperationRequest><aws:RequestId>ccf3f263-ab76-ab63-db99-244666044e85</aws:RequestId></aws:OperationRequest><aws:UrlInfoResult><aws:Alexa>
<aws:ContentData>
<aws:DataUrl type="canonical">google.com/</aws:DataUrl>
<aws:SiteData>
<aws:Title>Google</aws:Title>
<aws:Description>Enables users to search the world's information, including webpages, images, and videos. Offers unique features and search technology.</aws:Description>
<aws:OnlineSince>15-Sep-1997</aws:OnlineSince>
</aws:SiteData>
<aws:LinksInCount>3453627</aws:LinksInCount>
</aws:ContentData>
<aws:TrafficData>
<aws:DataUrl type="canonical">google.com/</aws:DataUrl>
<aws:Rank>1</aws:Rank>
</aws:TrafficData>
</aws:Alexa></aws:UrlInfoResult><aws:ResponseStatus xmlns:aws="http://alexa.amazonaws.com/doc/2005-10-05/"><aws:StatusCode>Success</aws:StatusCode></aws:ResponseStatus></aws:Response></aws:UrlInfoResponse>
ich benutzeroot.find('LinksInCount').text
Wert des Elements zu bekommen, aber es funktioniert nicht.
Ich möchte wissen, wie ich an den Text komme3453627
vonaws:LinksInCount