1

I need to get the core question asked on this page and so far this is the code I have used. The problem is that it brings me 'to next question' instead of the expected core question.

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument("--window-size=1200,850")
driver = webdriver.Chrome(ChromeDriverManager().install())

url = 'http://ipaulgraham.herokuapp.com/'      
driver.get(url)

for i in driver.find_elements_by_xpath("//*[contains(text(), 'question')]"):
    print(i.text)

--to next question

1 Answer 1

2

It seems that the question is inside a div that has question as its id. I guess you can do something like:

from selenium.webdriver.common.by import By
element = browser.find_element(By.ID, "question")
print(element.text)
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.