-1

Another location problem. I have renewed respect for you guys who do it for the top of your head since now I see how many cases you had to do to have it going on the first, maybe second try. My (and your) previous approaches don't work, again. Target page and the tag, I need the href.

<figure itemprop="associatedMedia" itemscope="" itemtype="http://schema.org/ImageObject">
    <a href="https://hasznaltauto.medija.hu/9250/13704508_1.jpg" itemprop="contentUrl" data-size="640x480">

These don't get me where I want.

find_elements_by_css_selector('figure > a')
find_elements_by_xpath("//figure[@imageprop='associatedMedia']/a[1]")
Dr Dro
  • 147
  • 2
  • 9
  • grab the outer `
    ` that is holding all the `figure` tags, then iterate over them
    – kstullich Nov 28 '18 at 22:16
  • Should I be going for an outer, regular tag as a regular practice? Because I feel like a dumbass asking every 12hrs about these problems. – Dr Dro Nov 28 '18 at 22:18
  • I would grab the outer tag since I am guessing you are wanting to grab all the `a` tags within the `figure` tags? It would make it easier on your side – kstullich Nov 28 '18 at 22:22

1 Answers1

1

This should work

driver.find_element_by_xpath("//*[@id='kepek-holder']/figure[1]/a").get_attribute('href')

In chrome, you can actually find the xpath of any element like this using developer tools.

JFYI: find_elements.. method will return an array(even if single match) of results and so you have to index the output to use the element.

Kamal
  • 2,384
  • 1
  • 13
  • 25
  • Thank you very much. It always seems I'm very close with my localization line but just not there. And I know about the array, I had it worked out pretty early and have and iterator down the line to deal with it. – Dr Dro Nov 29 '18 at 08:14