joelnazarene

DOAJ

Mar 31st, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 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://doaj.org/search?source={"query"%3A{"query_string"%3A{"query"%3A"'
  8.  
  9. b1=input("enter text \n")
  10. b2=b1.replace(" ","%20")
  11. b3='"%2C"default_operator"%3A"AND"}}%2C"from"%3A0%2C"size"%3A10}'
  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":'main-section'})
  20. containers=pagesoup.findAll("div",{"class":"abstract_text"})
  21. #print(containers[0].a['href'])
  22. #print("reached contA")
  23. i=0
  24. #u="https://www.scienceopen.com"
  25. for container in containers :
  26.  # print("for loop")
  27.   try :
  28.     if(len(container.text)>20):
  29.         i=i+1
  30.        
  31.        # print(i)
  32.         #if(i%2!=0):
  33.        
  34.         #   driver.get(u + container['href'])
  35.          #  refs=driver.page_source
  36.         #   s=soup(refs,"html.parser")
  37.           # c=s.find("div",{"itemprop":"description"})
  38.         print(container.text)
  39.         print("\n")
  40.   except :
  41.         continue
  42. driver.close()
Add Comment
Please, Sign In to add comment