Skip to content
This repository has been archived by the owner on Jul 21, 2022. It is now read-only.

post.caption is not returning right value #21

Closed
1999gauravgupta opened this issue Apr 26, 2021 · 28 comments
Closed

post.caption is not returning right value #21

1999gauravgupta opened this issue Apr 26, 2021 · 28 comments

Comments

@1999gauravgupta
Copy link

I was using this post as a reference- "https://www.instagram.com/p/CNrtoeOp_Et/"

Given caption= Photo shared by LLuvia Bakery on April 15, 2021 tagging @yogisthaan, @healthybuddhaorganic, @studioalaya_proj, fabcafe.in, @masmaracrafts, @Pronatureorganic, @ping_this, and @madansolanki10. May be an image of 5 people and text.

Original caption= It's been a long journey and we have nothing else filling our hearts today except gratitude.
Gratitude for the support and love and patience that everyone in the entire small business ecosystem has showered on us in the last few years. Nothing more to be said , just deep felt Thanks.

@yogeshwaran01
Copy link
Owner

@1999gauravgupta, you can use InstagramPost.text

>>> from instagramy import InstagramPost

>>> post = InstagramPost('CNrtoeOp_Et', sessionid=sessionid)

>>> post.text
"It's been a long journey and we have nothing else filling our hearts today except gratitude.\nGratitude for the support and love and patience that everyone in the entire small business ecosystem has showered on us in the last few years. Nothing more to be said , just deep felt Thanks."

caption is the description of the image identified by Instagram.
text is the original text provided by the user.

Thank You,

@1999gauravgupta
Copy link
Author

1999gauravgupta commented Apr 26, 2021

When reproducing your code I got this error.
Screenshot 2021-04-26 204446

Also, I am using this code :

account = InstagramUser(ig_name, sessionid=SESSION_ID) 
posts=account.posts
post=posts[0]

When printing the post object there doesn't seem to be any attribute named text. So I was using the next best option of a caption but I need a real caption provided by the user.
Kindly guide me in right direction and fix the issue ASAP.

@yogeshwaran01
Copy link
Owner

yogeshwaran01 commented Apr 26, 2021

@1999gauravgupta In the first issue, check your session-id once again it may be changed by Instagram.
In the second issue, Try is code

>>> account = InstagramUser(ig_name, sessionid=SESSION_ID) 
>>> posts = account.posts
>>> post_id = posts[0].shortcode

>>> post = InstagramPost(post_id, sessionid=SESSION_ID)
>>> post.text

Provide the correct session id

@1999gauravgupta
Copy link
Author

No, the session-id was correct. Even after fetching the new id, the error remains to be there.

@yogeshwaran01
Copy link
Owner

yogeshwaran01 commented Apr 26, 2021

Whenever the code executed properly without errors ?
If executed properly, login again into the Instagram in the browser and collect new session-id.

If code is always getting error, even onetime the code never get excuted. Please check the issue #17 for reference send me the output. I try to fix this issue.

@1999gauravgupta
Copy link
Author

1999gauravgupta commented Apr 27, 2021

There was no error while executing the issue #17 script.

Was not able to attach code file so here is the whole code of instagram.html

insta.txt

And output is
Screenshot 2021-04-27 101616

@yogeshwaran01
Copy link
Owner

yogeshwaran01 commented Apr 27, 2021

Please mention the error raised by the issue #17 script.

In your HTML file contains all required data. you mentioned error is raised when your session-id wrong or Instagram redirect to the login page. By your HTML file, Instagram does not redirect you to the login page. Login again into Instagram in the browser and collect new session-id and try again.

session-id

Please send your result.

@1999gauravgupta
Copy link
Author

I am getting no error just that post object is not having text property. But when using InstgramPost() constructor as mentioned by you to get posts opposed of InstgramProfile().posts. And then accessing text property it raises KeyError: graph ql.

I have double checked the session id and its correct and latest.

Also there was no error when using issue #17 script and I have also attached the generated output in previous comment.

I just want to access the text property using InstagramProfile().posts[0].text if that's possible.

@yogeshwaran01
Copy link
Owner

Try this #21 (comment)

@1999gauravgupta
Copy link
Author

image
The issue is account = InstagramUser('woollyfarms', sessionid=SESSION_ID) , this line does not gives error and comes before InstagramPost line and both of them uses same sessiondid so problem is with InstagramPost constructor not sessionid.
Gives this error

@yogeshwaran01
Copy link
Owner

check the following condition,

  • Check the variable name post_id by print(post_id). check whether is a post id
  • Don't use the same session id in the browser and with instagramy While code is executing don't use Instagram. If you use Instagram, the session id will be changed.

@1999gauravgupta
Copy link
Author

image
Yes, it was post id, first-line output shows it.
Yes, I wasn't using Instagram while instagramy was running.

@yogeshwaran01
Copy link
Owner

yogeshwaran01 commented Apr 27, 2021

@1999gauravgupta
Check the post id in the browser

https://www.instagram.com/p/<post_id>/

I checked the post id from the your screenshot it says "Sorry, this page isn't available."

Try any other post id

@1999gauravgupta
Copy link
Author

image
Seems to be correct.

@yogeshwaran01
Copy link
Owner

image

Same post, It is perfectly working for me, Check again

@1999gauravgupta
Copy link
Author

image

I don't know for what reason it doesn't work on my end but I am doing exactly same as you.

@yogeshwaran01
Copy link
Owner

Try any other Instagram post or try in google colab

@1999gauravgupta
Copy link
Author

#21 (comment)
Same error as this on google colab.

@yogeshwaran01
Copy link
Owner

It is impossible. I am unable to find the reason why it makes an error in your case but it is perfectly running in my local. you can try without session id

@1999gauravgupta
Copy link
Author

Works without sesson id but I won't be able to do much this way I guess.

@prays
Copy link

prays commented Apr 28, 2021

Hey, I have the same issue but in my experiment I found that I cannot use current session_id that is logged on in my instagram. In fact, you have to logged out from your account to use that session_id

@1999gauravgupta
Copy link
Author

Any update @yogeshwaran01 ?

@yogeshwaran01
Copy link
Owner

@1999gauravgupta Try this #21 (comment)

@1999gauravgupta
Copy link
Author

Nope doesn't work. Seems to be a weird bug.

@yogeshwaran01
Copy link
Owner

@1999gauravgupta ok I try to fix it

@mingjun1120
Copy link

I am currently facing the same issue and couldn't solve it!!!
image

But when I try to use the InstagramUser module, it is working fine.
image

@VagnerBelfort
Copy link

Hi!
I have the same error!!

Anyone managed to fix it?

@bug-author
Copy link

Same issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants