Good afternoon: I'm currently attempting to access the description (caption) section of certain instagram posts using python selenium. For instance, in the picture below it refers to the part that starts with the word "Thanks" and that goes all the way down to the hashtags.
Well, it caught my attention the following things:
Consider this post (https://www.instagram.com/p/CNYQkxADO8p/). When the inspector is checked, we can see that the comment is inside a class call "Edited" so we can retrieve all the text with the following code:
desc = driver.find_element_by_xpath("//span[@title='Edited']").text
The code above works well for the mentioned post. However, consider this second post: (https://www.instagram.com/p/CN5dOopjNEk/). The description seems to be located in a different HTML class, and the line of code above throws a NoSuchElementException. I was therefore wondering how can I access the caption of that post, considering that it is not located in a section by the title "Edited". How can I access said part of the post?
Thanks for your attention
