Answer the question
In order to leave comments, you need to log in
How to parse xml via url?
There is a URL ' data.alexa.com/data?cli=20&dat=snbamz&url=lol.com '
From it I should get a list of all domains (not TITLE)
import os
from urllib.request import urlopen
from xml.etree.ElementTree import parse
from xml.dom import minidom
url = ('http://data.alexa.com/data?cli=20&dat=snbamz&url=lol.com')
xmlinfo = parse(url)
for item in xmlinfo.iterfind('Alexa/RLS'):
domain = item.findtext('RL')
print(title)
Answer the question
In order to leave comments, you need to log in
XML
<!-- Need more Alexa data? Find our APIs here: https://aws.amazon.com/alexa/ -->
<ALEXA VER="0.9" URL="lol.com/" HOME="0" AID="=" IDN="lol.com/">
<RLS PREFIX="http://" more="0">
<RL HREF="www.wtf.com/" TITLE="WTF?!"/>
<RL HREF="www.nick.com/" TITLE="Nickelodeon Online"/>
<RL HREF="www.naver.com/" TITLE="네이버"/>
<RL HREF="www.miniclip.com/" TITLE="Miniclip"/>
<RL HREF="www.funnyjunk.com/" TITLE="Funny Junk"/>
<RL HREF="www.1001spill.no/" TITLE="1001 Spill"/>
<RL HREF="rofl.com/" TITLE="ROFL.com Staff Flash"/>
<RL HREF="omg.com/" TITLE="Object Management Group"/>
<RL HREF="lolcom.wordpress.com/" TITLE="LOL.com Development"/>
<RL HREF="chatango.com/" TITLE="Chatango - Add Free Live Chat to any Webpage"/>
</RLS>
<SD TITLE="A" FLAGS="" HOST="lol.com">
<OWNER NAME="ZWave, Llc"/>
</SD>
<SD>
<POPULARITY URL="lol.com/" TEXT="755256" SOURCE="panel"/>
<REACH RANK="662033"/>
<RANK DELTA="+133191"/>
</SD>
</ALEXA>
import xml.etree.ElementTree as et
import requests
url = 'http://data.alexa.com/data?cli=20&dat=snbamz&url=lol.com'
root = et.fromstring(requests.get(url).content)
result = [item.attrib.get('HREF') for item in root.findall('.//RL')]
['www.wtf.com/', 'www.nick.com/', 'www.naver.com/', 'www.miniclip.com/', 'www.funnyjunk.com/', 'www.1001spill.no/', 'rofl.com/', 'omg.com/', 'lolcom.wordpress.com/', 'chatango.com/']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question