import urllib import xml.etree.ElementTree as ET url = raw_input('Enter location: ') print 'Retrieving', url uh = urllib.urlopen(url) data = uh.read() print data print 'Retrieved',len(data),'characters' tree = ET.fromstring(data) counts = tree.findall('comment/comment') print counts the XML data format:
<comment> <name>Matthias</name> <count>97</count> </comment>
No comments:
Post a Comment