Advertisement
ranveer5289

user1063643

Jan 15th, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. from BeautifulSoup import BeautifulSoup, SoupStrainer
  2. import time, subprocess, httplib2, re
  3. import urllib
  4. f = urllib.urlopen("google.com";)
  5. lis=[]
  6. f.read()
  7. http = httplib2.Http()
  8. status, response = http.request('google.com';)
  9. #dictionary is returned by BeautifulSoup
  10. mydict =  BeautifulSoup(response, parseOnlyThese=SoupStrainer('a'))  
  11. #iterating dictionary on basic of key and value
  12. for key,value in mydict.iteritems():
  13. # check `href` key  present
  14.         if key == 'href':
  15.                 s=str(mydict['href'])
  16. #checking value corresponding to `href` starts with google.com
  17.                 x= s.startswith('google.com';)
  18.                 if x:
  19.                         print s lis.append(s)
  20.                         print lis
  21.                         for m in lis:
  22.                                 data = urllib.urlopen(m).read()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement