Advertisement
apl-mhd

Python scrap headline from daily star

Mar 19th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import  requests
  2.  
  3. from urllib.request import urlopen
  4.  
  5. webAdd = 'http://www.thedailystar.net/'
  6.  
  7. dailyStar = requests.get(webAdd)
  8. from bs4 import  BeautifulSoup
  9.  
  10. parsedHtml = BeautifulSoup(dailyStar.text, 'lxml')
  11.  
  12. headLine = parsedHtml.find_all('a')
  13.  
  14. #findAll('table', {'class':'theclass'} ):
  15.  
  16.  
  17. link = parsedHtml.find_all('a')
  18.  
  19. print(len(link))
  20.  
  21. for i in range(len(link)):
  22.     if link[i].parent.name == 'h3':
  23.         print("http://www.thedailystar.net/" + link[i].get("href") +'\n')
  24.         print(link[i].text + '\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement