from xml etree ElementTree import ElementTree as ET fromstring from ur

1
2
3
4
5
6
7
8
>>> from xml.etree.ElementTree import ElementTree as ET, fromstring
>>> from urllib import urlopen
>>> data = urllib.urlopen('http://blograte.ru/opml-1.php').read()
>>> tree = fromstring(data)
>>> len(tree.findall('body/outline/outline'))
634
>>> items = [x.get('htmlUrl') for x in tree.findall('body/outline/outline')]
>>> file('/tmp/blogs', 'w').write('\n'.join(items))