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
Extracting Data From XML
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)
Day 17 of #100DaysOfCode and #Python
— Durga Pokharel (@mathdurga) January 10, 2021
* I learned about python access on web data
* Did some challenge on extensible markup language
* Extracting data from XML pic.twitter.com/9us9a4c1zn
Top comments (0)