Trouble accessing Instagram post caption in Python Selenium Trouble accessing Instagram post caption in Python Selenium selenium selenium

Trouble accessing Instagram post caption in Python Selenium


For that specific post you can try using:

desc = driver.find_element_by_xpath("//div[@class='C4VMK']/h2/following-sibling::span")print(desc.text)

Since there is no direct way to access that element, we drill down from the class to h2 and then take the next element sibling of span, which is where the text resides.

I am not sure why it would be different from the other posts that have //span[@title='Edited'], but it seems to be.