/ Published in: Python

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import urllib2 import xml.dom.minidom source = urllib2.urlopen('http://www.bbc.co.uk/') #data = repr(source.read()); doc = xml.dom.minidom.parse(source) all = doc.getElementsByTagName("h3") for h3 in all : parent = h3.parentNode if (parent.getAttribute("id") == "promo_area"): child = h3.childNodes[1] child = child.childNodes[2] print ("\nPresent Headline : ") print (child.data+ "\n")
Comments
