Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Check 12th Class Result Using Selenium in Python

  • Difficulty Level : Medium
  • Last Updated : 04 Jan, 2021

We are going to collect the data of 12th class in CSV file with the following information:

  1. Candidate name
  2. Pass or fail status
  3. Division
  4. Obtain marks

This task will be done by using selenium library of Python.

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course


You need to install chrome driver and set path. Click here To download. For more information follow this link


  1. First to go 12th website follow this LINK(this is for up board 12th result).
  2. Then click on investigate element by urgent ctrl + shift + i or stepping into setting of browser and clicking on investigate detail manually.
  3. Then navigate to the box where the district is select then copy the x_path.
  4. Then navigate to the box where the roll number is filled then copy the x_path.
  5. Then navigate the view result button then copy the x_path.
  6. I want to store the result in CSV file then also navigate student name, fail-pass status, division, obtain marks. Then fill up roll number automatically by script go to next page find x_path of student name, fail-pass status, division, obtain marks.

Follow step-by-step with the help of screenshots and copy the x_path of element and put into the code:

Step 1:

Step 2:

Step 3:

Step 4:

Step 5:

Step 6:

Step 7:

Step 8:

Step 9:

Step 10:

Step 11:

Step 12:

Below is the implementation:


# import required libraries
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from import Select
from selenium.common.exceptions import NoSuchElementException
import csv 
import time
# give name of csv file
filename = "abc.csv"
# open file in write mode
f = open(filename, 'w')
# creat header in file
header = "NAME,STATUS,DIV,NUM\n"
# write into the file
# put rollnumber without zero like
# your number 0477593 then
# put 477593 upto XXXXX.
start_rollNum = 926840
end_rollNum = 926841
# put range of rollnumber
for i in range(start_rollNum, end_rollNum ):
    # use try and except because if any rollnumber
    # is invalid then whole program is not stop.
        driver = webdriver.Chrome()
        # link is given above copy and paste
        # add zero in rollnumber in starting
        t = '0' + str(i)
        # district xpath
        state = driver.find_element_by_xpath('//*[@id="ctl00_cphBody_ddl_districtCode"]')
        drp1 = Select(state)
        # select district
        # put rollnumber
        # view result xpath
        # student name
        name = driver.find_element_by_xpath('//*[@id="ctl00_cphBody_lbl_C_NAME"]').text
        # status pass or fail
        status = driver.find_element_by_xpath('//*[@id="ctl00_cphBody_lbl_RESULT"]').text
        # division
        div = driver.find_element_by_xpath('//*[@id="ctl00_cphBody_lbl_DIVISION"]').text
        # obatin marks
        num = driver.find_element_by_xpath('//*[@id="ctl00_cphBody_lbl_MRK_OBT"]').text
        # all details fill into csv file
        f.write(name + "," + status + "," + 
                div[1 : ] + "," + num + "\n")
        # close the driver
    except NoSuchElementException as exception:
# close and save the file


CSV file screenshot

Note: If you Want to find a topper then apply a filter on CSV file.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!