from
selenium
import
webdriver
from
selenium.webdriver.common.keys
import
Keys
from
selenium.webdriver.support.ui
import
Select
from
selenium.common.exceptions
import
NoSuchElementException
import
csv
import
time
filename
=
"abc.csv"
f
=
open
(filename,
'w'
)
header
=
"NAME,STATUS,DIV,NUM\n"
f.write(header)
start_rollNum
=
926840
end_rollNum
=
926841
for
i
in
range
(start_rollNum, end_rollNum ):
try
:
driver
=
webdriver.Chrome()
t
=
'0'
+
str
(i)
state
=
driver.find_element_by_xpath(
'//*[@id="ctl00_cphBody_ddl_districtCode"]'
)
drp1
=
Select(state)
drp1.select_by_visible_text(
'LUCKNOW'
)
driver.find_element_by_xpath(
'//*[@id="ctl00_cphBody_txt_RollNumber"]'
).send_keys(t)
driver.find_element_by_xpath(
'//*[@id="ctl00_cphBody_btnSubmit"]'
).click()
name
=
driver.find_element_by_xpath(
'//*[@id="ctl00_cphBody_lbl_C_NAME"]'
).text
status
=
driver.find_element_by_xpath(
'//*[@id="ctl00_cphBody_lbl_RESULT"]'
).text
div
=
driver.find_element_by_xpath(
'//*[@id="ctl00_cphBody_lbl_DIVISION"]'
).text
num
=
driver.find_element_by_xpath(
'//*[@id="ctl00_cphBody_lbl_MRK_OBT"]'
).text
f.write(name
+
","
+
status
+
","
+
div[
1
: ]
+
","
+
num
+
"\n"
)
driver.close()
except
NoSuchElementException as exception:
continue
f.close()