-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tweepy not getting full text #935
Comments
If the tweet has 280 chars the JSON returned by Twitter will contain the More details on the extended tweet API here: https://developer.twitter.com/en/docs/tweets/tweet-updates |
@jaycech3n hey, you're correct, thank you for that. I assumed I was already using
Cheers |
Hello,
is there also a |
also interested in knowing. |
Hello, For the search API would you do the same? example: api.search(q="query", tweet_mode="extended") Thanks. |
Hello, twitter_name = input("Enter a Twitter Handle: ")
for name in twitter_name:
try:
stuff = api.user_timeline(screen_name = twitter_name, count = 100, include_rts = False)
except tweepy.TweepError as e:
twitter_name = input("The handle you entered was invalid, please try again: ")
catchcount = 0 Returns the tweet followed by '...' then a link. Ideally would like to return the full tweet. Is there a way to do that while still using the |
I tried using the tweet_mode="extended" add on as show in the code but still there are a couple of tweets getting truncated. Code :
Any idea why this is happening ? Output :
|
@varadhbhatnagar change all instances of |
@vism2889 Also , I am getting rate limited error 420 too often. Is there a way I can make that go away? |
@varadhbhatnagar So theres some info regarding handling errors on the bottom of this linked page http://docs.tweepy.org/en/v3.5.0/streaming_how_to.html , but it looks like it will disconnect your stream which i don't think you want. More info regarding rate limiting https://developer.twitter.com/en/docs/basics/rate-limiting.html . Do you have anymore code than what you've posted above? If so please post it. |
@vism2889 I read the link and handled the rate limiting issues pretty well . Also , I tried using full_text and here is the error that I am getting : AttributeError: 'Status' object has no attribute 'full_text' Here is the complete code now :
|
@varadhbhatnagar hmm, personally havent used the streamlistener very much. You do have an instance of status.text still in this code right before |
I have changed my tweet_mode to 'extended' and I have replaced all instances of '.text' to '.full_text' but there are still tweets that are being truncated. My code:
Example result: RT @WiCnet: Time for some news about filming on #GameofThrones season 8. We've got some intriguing new shots of the massive King's Landing… |
This comment has been minimized.
This comment has been minimized.
@varadhbhatnagar is this function part of Tweepy or was it created by you? |
@Flyer4109 . Hi. The on_data functionality is a part of tweepy. Since tweepy is poorly documented, I referred to this link and went through a couple of examples when I wanted to understand how on_data() worked. |
@varadhbhatnagar @vism2889 @trtm @kodeine Note that the developer documentation says that using |
@Flyer4109 There is no issue, in your case the ellipsis is an actual part of the tweet's full text, and not a truncation. This is the usual behavior for retweets. |
@jaycech3n Ah thank you, that has sorted it out |
def get_all_tweets(screen_name):
from urllib import urlopen pass if name == 'main': Hi guys - I'm new to python and I'm trying to stop my tweets from being truncated. I added an extended tweet mode but I get this error. " AttributeError: 'Status' object has no attribute 'text'" Also, does anyone know the code to remove the URL from the output too? My tweets look like this: "The Trump administration released a list of 210 people who were identified because of their "closeness to the Russi… https://t.co/5NmKPtQNrO"THANK YOU!!! |
Even using the extended_tweet modality (suggested by @jaycech3n), I was getting truncated tweets (and strangely, the flag "truncated" was set to False). Actually, the problem arises for "retweeted" tweets. So, to avoid this problem, you need to get the "full_text" from the "retweeted_status", when available:
|
@gabrer, I'm able to get the full text in a streaming listener by using Likewise, the (basic) entities in the full tweet are available from |
For those who try
Hat tip to this StackOverflow post. |
I'm able to get full text in api.timeline but unable to get full text in api.statuses_lookup.
|
try this out. I guess you have to consider the retweeted_status attribute for retweets.
|
Is there any way to get full text for RT in the api.search? I need to use this for retrieving past tweets (ex. tweets between 8 days ago and 2 days ago). I used the mentioned method above for status..text convert to status.full_text but does not work. I know that this works for on_data() but I also need it for the other situation. |
The following is the answer including processing for many different situations (no satisfying answers are avaliable online. I got it after many anonying hours of error and trial). Hope it helps. |
This comment has been minimized.
This comment has been minimized.
Regarding the api.search() method, neither the use of tweet_mode='extended' nor compression=False seems to hinder the api from truncating text. |
@varadhbhatnagar i am currently having the same Problem, and you seem to be the only to have ever solved it. But unfortunatly i cant get your code to work. what do i have to write into the on_data function to get even the full Retweets. |
And I'm having the same problem.... Any new ideas? |
@ValnirJr I solved it, will post my code later today or tomorrow. The thing is you need to access the tweet element in the json file. For Example: |
As Twitter’s Tweet updates documentation explains, Twitter's API only provides extended Tweets when using extended mode. I've added a section in Tweepy's documentation that covers extended Tweets to supplement Twitter's documentation.
This is only true for streams.
Extended mode returns the same type of Status object. It simply replaces the
This should not be the case. Extended Tweets will not have a
This isn't relevant to this issue. Like you said, you're being rate limited by Twitter's API. This isn't an issue with Tweepy, and you can simply not hit the rate limit to not get rate limited.
Status objects from streams use compatibility mode with an additional
This is not the case. Not only is @Flyer4109 not using a stream (and therefore not using the data event handler), but the Status object provided to the Status event handler should be fully representative of the corresponding data provided to the data event handler.
The @jaycech3n @varadhbhatnagar @vism2889 @trtm @kodeine
This shouldn't be necessary, as the Status object provided to the Status event handler should be fully representative of the corresponding data provided to the data event handler.
This is not the case, as that is not the full text of the Retweeted Tweet. It is true however, that the @AttributeErrorCat Also, that is the normal text for a truncated Tweet. You can simply use the full, untrucated text instead. For code block usage, see https://help.github.com/articles/creating-and-highlighting-code-blocks/. @gabrer This is normal behavior for Retweets. @shaharyar2643 For code block usage, see https://help.github.com/articles/creating-and-highlighting-code-blocks/. @chaoswjz Yes, you can simply use extended mode. That is the only time the @wangcongcong123 Also, you should be able to use the Status attributes, as the Status object should be fully representative of the corresponding JSON data used to generate it. For code block usage, see https://help.github.com/articles/creating-and-highlighting-code-blocks/. @tushar2899 That has nothing to do with this issue. @ottok92 That should not be the case. Are you sure they are not Retweets? If so, can you provide a reproducible example (MCVE/SSCCE)?
That's clearly not the case, as there are multiple better examples and explanations afterwards in this thread.
I'm not sure what JSON file you're referring to, but if you mean the data event handler or the Status object's JSON data, that shouldn't be necessary, as the Status object provided to the Status event handler should be fully representative of the corresponding data provided to the data event handler and used to generate the Status object. This code will error if For code block usage, see https://help.github.com/articles/creating-and-highlighting-code-blocks/. |
This comment has been minimized.
This comment has been minimized.
Please don't necro-bump old closed issues. See the Extended Tweets section of the documentation. For code block usage, see https://docs.github.com/en/free-pro-team@latest/github/writing-on-github/creating-and-highlighting-code-blocks. |
Hey guys, just a heads up that currently the library is not getting the new tweets. According to the following example:
https://developer.twitter.com/en/docs/tweets/tweet-updates#chars280
Notice that currently tweepy is retrieving only 140 chars and then adding "..." at the end. Any of you guys now if there is any easy fix for that? Or is this a problem from Twitter?
The text was updated successfully, but these errors were encountered: