My question aim: To get the Name of the candidate (which is a part of a HTML Table) and write it into a file.
(my entire program, in point 2, aims at: Typing a register number in a website, hitting submit, getting the name of the candidate (which is the problem), putting the registration number with name in a file, then going back and repeating the same till the last number.) The table looks as follows: HTML TABLE IN THE SITE
- The HTML Code, only for the table is as follows:
<table id="details" class="table">
<tbody>
<tr>
<td width="15%">Name</td>
<td width="85%" colspan="3"><span style="font-weight: bold"> ANILKUMAR </span></td>
</tr>
<tr>
<td>Reg. No.</td>
<td colspan="3"><span style="font-weight: bold"> 461684</span></td>
</tr>
</tbody>
</table>
2.My PYTHON code , as specified according to the aim,
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import pyautogui,pyperclip
#Function.
def fun1(roll_no):
while(i<999999):
#INPUT: Put's the number in text bar, in Home Page, then clicks "Submit"
inputElement = browser.find_element_by_id("reg")
inputElement.send_keys(roll_no)
inputElement.send_keys(Keys.ENTER)
#SNIPPET TO GET THE NAME OF CANDIDATE, HOW?
#fs.write(str(i)+'\t'+name+'\n') , to WRITE INTO FILE.
#'name' in above line refers to the candidate's name, a string.
#OUT: Click's the "Back" button to go back to Home Page.
outputElement = browser.find_element_by_link_text('Back')
outputElement.click()
roll_no = roll_no + 1
#MAIN MODULE
#OPENS Firefox using selenium webdriver
browser = webdriver.Firefox()
#The intended "Home Page"
browser.get("http://karresults.nic.in/indexpuc_2016.asp")
roll_no=110000 #Starting Roll Number.
#File open for writing.
fs=open("testfile.txt","w")
#call the function
fun1(i)
- The Name of the candidate is always at row=0,col=1. All I need is to access the cell having the name, using selenium. I don't need to loop through all the cells. Please help me, I'm pretty new to Python and Selenium Webdriver Utility. Also, I've a link included of the picture above(I can't post pictures directly, as I've new, this is my first question and thus no reputation). Any help will be greatly appreciated. Thank You!