joelnazarene

sciend

Mar 30th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. import time
  2. import bs4
  3. import re
  4. from selenium import webdriver
  5. from bs4 import BeautifulSoup as soup
  6. driver = webdriver.Firefox()
  7. url="https://www.sciencedirect.com/search?qs="
  8. b3="&show=25&sortBy=relevance"
  9.  
  10. b1=input("enter text \n")
  11. b2=b1.replace(" ","%20")
  12. #print(b2)
  13. print("\n\n")
  14. url=url+b2+b3
  15. driver.get(url)
  16. time.sleep(2)
  17. refs=driver.page_source
  18. pagesoup=soup(refs,"html.parser")
  19. #containers=pagesoup.findAll("div",{"class":'result-item-content'})
  20. containers=pagesoup.findAll("a",{"href":re.compile('/pii/.*')})
  21. #print(containers)
  22.  
  23. i=0
  24. u="https://www.sciencedirect.com"
  25. for container in containers :
  26.  
  27.     if(len(container.text)>20):
  28.         i=i+1
  29.        
  30.        # print(i)
  31.         if(i%2!=0):
  32.        
  33.            driver.get(u + container['href'])
  34.            refs=driver.page_source
  35.            s=soup(refs,"html.parser")
  36.            c=s.find("div",{"id":"abstracts"})
  37.            print(c.text)
  38.         print("\n")
  39.  
  40. driver.close()
Add Comment
Please, Sign In to add comment