joelnazarene

yh

Apr 24th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. import bs4
  2. from urllib import urlopen as uReq
  3. from bs4 import BeautifulSoup as soup
  4. myurl="https://search.yahoo.com/yhs/search?hspart=ddc&hsimp=yhs-linuxmint&type=__alt__ddc_linuxmint_com&p="
  5. a="jesus"
  6. b=raw_input('enter the keyword \n\n')
  7. myurl=myurl+b
  8.  
  9. uClient=uReq(myurl)
  10. pagehtml=uClient.read()
  11. uClient.close()
  12. pagesoup=soup(pagehtml,"html.parser")
  13. containers=pagesoup.findAll("h3",{"class":"title"})
  14.  
  15.  
  16. for container in containers :
  17.    if len(container.a['href']) < 80  :
  18.          print(container.a['href'])
  19.          print("\n")
  20. #print(pagesoup)
  21. #filename="products2.csv"
  22. '''f=open(filename,"w")
  23. headers="brand"
  24. f.write(headers)
  25.  
  26.  
  27. for container in containers :
  28.     brand = container.a.img["title"]
  29.     #print("\n"+brand)
  30.     f.write("\n" + brand)
  31.  
  32. f.close()'''
Add Comment
Please, Sign In to add comment