Python Selenium - Getting Instagram 'href'?!?!?!?!!??!?!?!?!?!??!

CoderFromHell

Power Member
Joined
Mar 19, 2019
Messages
727
Reaction score
341
Using selenium Im trying to pull a href link from my Instagram timeline. Can't seem to get the code right.
Python:
PostLinkExtraction = driver.find_element_by_xpath("//article[1]/div[3]/div[2][*[local-name()='a']]")
    print (PostLinkExtraction)

The href should be pulled from the <time> tag on Instagram:
Photo Jan 31, 6 22 32 PM.jpg
 
Perhaps try the following approach;
Python:
driver.find_elements_by_xpath("//*[contains(text(), 'hours ago')]")
 
To add a bit more context, when I do get_attribute[‘href’] it also returns none. But appreciate the replies, soon as I get home I’ll be trying some of these responses.
 
I often print the entire page's source from selenium and do a quick search for the content I'm looking for. Often it can be quite different to what you see in a browser due to multiple reasons.
 
Back
Top