Srinivas Venkataram
Srinivas Venkataram

Reputation: 47

Selenium code to read the value from HTML (WebScraping)

Am trying to read few values from website. I want to read the Value of Number of Articles from the below website. I want to store the value 1 in a variable to be used later. Am stuck here and not able to proceed further. Any help is much appreciated. enter image description here

Below is the screen shot of the HTML code when I press inspect element on Number of articles. enter image description here

I have tried the below codes but for no use

mBrowser.find_element_by_name("ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder1$TxtTotLines").text
mBrowser.find_element_by_name("ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder1$TxtTotLines").Value

Please help me. Thank you

Upvotes: 0

Views: 33

Answers (1)

Y.Berrama
Y.Berrama

Reputation: 101

To get the attribute value you have to use get_attribute function and specify in parameter the attribute that you want to read.

In your case it will be :

mBrowser.find_element_by_name("ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder1$TxtTotLines").get_attribute('value')

You can have more details here : Selenium API documentation

Upvotes: 1

Related Questions