I am scraping images from a website, but the xpath varies for the element. I read this post that an or function can be used by doing find_elements_by_xpath.
However, when I tried replicating the example, I could no longer extract the src of the image. Am I doing the or function wrong?
images=driver.find_elements_by_xpath('// img[ @ id = "ember51"]' or '// img[@id="ember52"]')
print(images.get_attribute('src'))
Error:
AttributeError: 'list' object has no attribute 'get_attribute'
I attempted to make a for loop, so the src could be scraped:
images=driver.find_elements_by_xpath('// img[ @ id = "ember51"]' or '// img[@id="ember52"]')
for image in images:
print(images.get_attribute('src'))
But when I use a for loop, I get the same error. Not sure how to make this work.