I'm trying to grab content that loads dynamically using selenium via python3 after page load. I tried every solution I could find here but none of them works.
Specifically what I need is the value of href, but for now just being able to retrieve the entire page source with all the content after page-load would work as well.
Example of href value I need:
<a class="class1 class2" href="/path1/path2/path3/lsdkfughjfsldkfghsdlf">
I tried the following:
WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".class1.class2")))
Which errors with this:
WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".Image-image")))
File "C:\Users\Mike\PycharmProjects\pythonProject\venv\lib\site-packages\selenium\webdriver\support\wait.py", line 89, in until
raise TimeoutException(message, screen, stacktrace)
If I remove that and try this:
page_source = driver.page_source
driver.close()
with open(r"output.txt", "w") as f:
f.write(page_source)
Then I just get the loaded HTML page.
Additional configurations I am using that may be helpful in finding a solution:
s = Service("chromedriver.exe")
options = Options()
options.add_argument('user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) ''Chrome/94.0.4606.81 Safari/537.36')
driver = webdriver.Chrome(options=options,service=s)
Any direction would be greatly appreciated!