Is it possible to only download the caption (the description) of a post, given the post short code, using python 3.12 and the latest version of the instaloader library? I am insterested in using instaloder as a library module, not the cli utility.
If not, can you suggest another similar python library that would allow me do so?
Im I correct in thinking that instagram API does not allow doing so for a non-user posts?
Update: the solution is in the accepted answer. The full code is below
import instaloader
L = instaloader.Instaloader()
post = instaloader.Post.from_shortcode(L.context, SHORTCODE)
print(post.caption)
As per the documentation of Instaloader, you do have access to downloading the caption of the post: https://instaloader.github.io/module/structures.html#instaloader.Post.caption
And you can probably load the library first and create an instaloader instance and then run a sample code snippet as follows:
# Loading a post using its shortcode
post = instaloader.Post.from_shortcode(L.context, 'ShortCode')
# Print the caption of the post
print(post.caption)