My first python script


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import urllib2
  2. import xml.dom.minidom
  3.  
  4. source = urllib2.urlopen('http://www.bbc.co.uk/')
  5. #data = repr(source.read());
  6.  
  7. doc = xml.dom.minidom.parse(source)
  8.  
  9. all = doc.getElementsByTagName("h3")
  10.  
  11. for h3 in all :
  12. parent = h3.parentNode
  13. if (parent.getAttribute("id") == "promo_area"):
  14. child = h3.childNodes[1]
  15. child = child.childNodes[2]
  16. print ("\nPresent Headline : ")
  17. print (child.data+ "\n")

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.