coding cp1251 import urllib import xml dom minidom def prints datas fo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: cp1251 -*-
import urllib
import xml.dom.minidom
def prints(datas):
for data in datas:
print getText(data.childNodes)
def getText(nodelist):
rc = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc
doc = xml.dom.minidom.parse(urllib.urlopen('http://db.linkfeed.ru/1985af609496ee9ff0189319274a7f20c50b483e/seeblog.ru/DEFAULT.xml'))
pages = doc.getElementsByTagName('pages')
for page in pages:
print page.getElementsByTagName('page')[0].attributes["url"].value
for level in page.getElementsByTagName('page')[0].getElementsByTagName('level'):
print page.getElementsByTagName('page')[0].getElementsByTagName('level')[0].childNodes[0].data
for level in page.getElementsByTagName('page')[0].getElementsByTagName('link'):
print page.getElementsByTagName('page')[0].getElementsByTagName('link')[0].childNodes[0].data