runnig

urllib2

Aug 13th, 2015
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. import urllib2
  2. import re
  3.  
  4. urls = ["http://www.youtube.com/watch?v=kPhZDsJUXic","http://www.google.com"]
  5. i = 0
  6. regex = '<title>(.*)</title>'
  7. pattern = re.compile(regex)
  8.  
  9. while i< len (urls):
  10.    response = urllib2.urlopen(urls[i])
  11.    htmltext = response.read()
  12.    titles = re.findall(pattern, htmltext)  
  13.    print titles
  14.    i+=1
  15.    response.close()
Advertisement
Add Comment
Please, Sign In to add comment