Posted By

a1ananth on 01/08/11


Tagged

data web scraping


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

rvachere


My first python script


 / Published in: Python
 

  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  

You need to login to post a comment.