Answer the question
In order to leave comments, you need to log in
How to copy a domain on selenium?
I wrote the code
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://gdz-putina.net/11-klass-algebra-mordkovich#task?t=prgrph-1-1")
content = driver.find_element_by_css_selector('.task img ')
content.click()
content1 = content.find_element_by_tag_name(img)
src = content1.get_attribute('src')
print(src)
Answer the question
In order to leave comments, you need to log in
first: you need to add the location address of your chromedriver.exe file
second: it is important to wait for the element you need to load on the page - for this, use WebDriverWait
and third: in adding content1 - I forgot the quotes to the tag name.
In general, it works for me with the following code (enter your own value for path):
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
path = 'C:\Python34\my_progs\chromedriver.exe'
driver = webdriver.Chrome(executable_path=path)
driver.get("https://gdz-putina.net/11-klass-algebra-mordkovich#task?t=prgrph-1-1")
WebDriverWait(driver, 20).until(
lambda d: d.find_element_by_class_name('task'))
content = driver.find_element_by_class_name('task')
WebDriverWait(content, 20).until(
lambda d: d.find_element_by_tag_name('img'))
content = content.find_element_by_tag_name('img')
content.click()
WebDriverWait(driver, 20).until(
lambda d: d.find_element_by_tag_name('img'))
content1 = driver.find_element_by_tag_name('img')
src = content1.get_attribute('src')
print(src) # https://gdz-putina.net/attachments/images/tasks/000/001/887/0002/5a6491b599d46.png
driver.quit()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question