0

I want to access a value on a website where I pull data. This value is a value when clicked on. However, I want to do it without clicking, because there are bot blockers, I should not interact too much. When I press f12, the value appears, but I cannot reach this value because it does not appear on the page. How can I do it.

website's html

<div onclick="TextClick(0)"  class="classname">Click and see value</div>
<div id="details" class="Box">
    <label>value</label>
</div>

my code bot.py

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import os
browser = webdriver.Chrome()


browser.get('https://www.examplewebsiteinhere.com')
print(browser.find_element_by_css_selector('#Details > label').text)

Thank you

1
  • Can you run the JS function TextClick(0) directly? Commented Jan 13, 2021 at 14:09

1 Answer 1

1
print(browser.find_element_by_css_selector('#Details_0 > label').get_attribute("textContent"))

Using get_attribute("textContent") can retrieve text not displayed in ui but is available in the dom

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.