This is my day 17th of #100Daysofcode. Today I also continue to learned about python access on web data in Coursera..
Did many challenge in HTML regarding to the topic Introduction to the Responsive web Design challenge in Freecodecamp
Extensible markup language is a language that define set of rule for encoding documents in a formate that is both human readable and machine .
My code start from importing from urllib
request and importing
xml.etree.ElementTree as ET.
from urllib import request import xml.etree.ElementTree as ET
The program will prompt for a URL, read the XML data from that URL using urllib and then parse and extract the comment counts from the XML data, compute the sum of the numbers in the file.
url = "http://py4e-data.dr-chuck.net/comments_1113374.xml" print ("Retrieving", url) html = request.urlopen(url) data = html.read() print("Retrieved",len(data),"characters") tree = ET.fromstring(data) results = tree.findall('comments/comment') icount=len(results) isum=0 for result in results: isum += float(result.find('count').text) print(icount) print(isum)