iSarabjitDhiman / TweeterPy

TweeterPy is a python library to extract data from Twitter. TweeterPy API lets you scrape data from a user's profile like username, userid, bio, followers/followings list, profile media, tweets, etc.
MIT License
123 stars 17 forks source link

Tweet Dates #22

Closed Allen-Taylor closed 11 months ago

Allen-Taylor commented 11 months ago

Maybe I am doing something wrong, but the tweet dates seem to be all over the place for the guest tokens.

Is there a method to grab the latest tweets?

Thank you for your work.

from tweeterpy import TweeterPy
twitter = TweeterPy()
twitter.load_session("Twitter Saved Sessions/session.pkl")
tweets = twitter.get_user_tweets('AltCryptoGems')

for data in tweets['data']:
    print(data['content']['itemContent']['tweet_results']['result']['legacy']['created_at'])

API Updated Successfully. Wed Nov 23 10:59:33 +0000 2022 Fri Oct 21 17:01:00 +0000 2022 Sun Oct 02 14:28:20 +0000 2022 Sun Apr 09 17:00:02 +0000 2023 Thu Aug 18 12:30:00 +0000 2022 Mon Aug 15 17:31:36 +0000 2022 Thu Sep 01 16:00:01 +0000 2022 Wed May 03 20:15:00 +0000 2023 Mon Jul 18 08:00:01 +0000 2022 Mon May 17 18:22:17 +0000 2021 Sun Jul 23 10:58:46 +0000 2023 Mon May 22 16:00:01 +0000 2023 Mon May 31 07:24:39 +0000 2021 Mon Apr 11 18:42:00 +0000 2022 Tue Feb 07 19:30:00 +0000 2023 Sun Aug 06 07:04:00 +0000 2023 Mon Jul 11 09:43:00 +0000 2022 Tue Sep 20 17:00:07 +0000 2022 Sat Feb 25 13:00:00 +0000 2023 Fri Nov 04 18:30:17 +0000 2022 Mon Nov 14 18:30:15 +0000 2022 Mon Oct 17 17:30:05 +0000 2022 Fri Oct 14 17:30:05 +0000 2022 Wed Mar 15 17:01:00 +0000 2023 Fri Nov 11 18:30:14 +0000 2022 Sun Mar 05 19:03:33 +0000 2023 Tue Jul 04 16:59:00 +0000 2023 Fri Nov 18 18:30:15 +0000 2022 Tue May 11 07:58:24 +0000 2021 Fri Sep 30 15:00:05 +0000 2022 Mon Oct 10 17:30:15 +0000 2022 Thu Sep 15 16:50:49 +0000 2022 Wed Jul 20 15:00:02 +0000 2022 Mon Nov 07 18:30:17 +0000 2022 Mon Oct 31 18:30:10 +0000 2022 Tue Nov 08 21:40:04 +0000 2022 Tue May 17 10:09:31 +0000 2022 Thu Oct 27 13:26:38 +0000 2022 Mon Sep 26 16:55:03 +0000 2022 Wed Jan 05 12:33:18 +0000 2022 Thu Jul 14 12:00:02 +0000 2022 Tue Jul 05 10:00:01 +0000 2022 Sun Jun 26 19:33:16 +0000 2022 Tue Apr 04 18:04:10 +0000 2023 Mon Jun 13 09:01:00 +0000 2022 Thu Jul 28 16:00:01 +0000 2022 Mon Jun 20 10:00:04 +0000 2022 Sat Aug 06 08:58:09 +0000 2022 Fri Dec 16 18:45:04 +0000 2022 Sat Jun 25 17:14:00 +0000 2022 Wed Oct 05 10:40:04 +0000 2022 Wed Sep 15 13:29:23 +0000 2021 Tue Aug 02 16:00:02 +0000 2022 Thu Sep 29 09:05:04 +0000 2022 Fri Dec 02 18:45:03 +0000 2022 Mon Feb 20 18:01:24 +0000 2023 Sun Oct 09 11:30:04 +0000 2022 Wed Sep 28 16:00:02 +0000 2022 Fri Oct 28 16:10:05 +0000 2022 Thu Jan 26 09:01:30 +0000 2023 Fri Aug 12 12:00:02 +0000 2022 Mon Feb 06 22:48:38 +0000 2023 Fri Jul 01 08:56:00 +0000 2022 Wed Oct 26 20:40:08 +0000 2022 Wed Oct 26 14:05:04 +0000 2022 Mon Apr 26 11:43:50 +0000 2021 Mon Jul 25 19:36:00 +0000 2022 Sun Oct 09 06:10:02 +0000 2022 Sat Oct 08 06:10:03 +0000 2022 Wed Oct 26 17:00:06 +0000 2022 Tue Sep 27 10:40:04 +0000 2022 Fri Jul 08 09:57:57 +0000 2022 Sat Nov 20 09:29:13 +0000 2021 Thu Jun 02 09:25:00 +0000 2022 Wed Oct 26 21:10:05 +0000 2022 Tue Jan 04 17:13:49 +0000 2022 Wed Jun 07 19:00:01 +0000 2023 Wed Sep 28 20:40:08 +0000 2022 Fri Sep 30 12:15:06 +0000 2022 Sun Oct 09 18:35:02 +0000 2022 Tue May 11 18:31:31 +0000 2021 Tue Aug 01 07:01:00 +0000 2023 Tue Dec 06 18:00:02 +0000 2022 Wed Oct 26 15:00:12 +0000 2022 Sat Oct 08 10:40:02 +0000 2022 Mon Jun 06 12:01:00 +0000 2022 Mon Aug 30 18:57:00 +0000 2021 Thu Dec 15 18:59:17 +0000 2022 Wed Sep 28 21:10:05 +0000 2022 Sun Jan 08 20:53:49 +0000 2023 Sat Nov 13 09:04:02 +0000 2021 Mon Oct 03 15:00:08 +0000 2022 Fri Dec 23 15:00:02 +0000 2022 Wed Oct 26 18:35:06 +0000 2022 Thu Jan 13 11:45:00 +0000 2022 Tue Nov 02 20:22:32 +0000 2021 Sat Dec 17 12:22:02 +0000 2022 Sun May 22 18:55:00 +0000 2022 Mon Dec 26 18:45:03 +0000 2022 Mon Aug 01 08:13:44 +0000 2022

iSarabjitDhiman commented 11 months ago

Hey @Allen-Taylor

You are doing it all right. I just want to point out that twitter by default also shows "promoted" and "reposted" tweets. So the reason these dates are not in order is that the promoted or reposted tweets are included in this dataset and were posted back in the time. So you will have to filter them out.

Take a look at this.

You might also be interested in taking a look at the "entryId" which basically tells us the type of dataset/tweet whether it's promoted, tweet thread or reposted etc.

Allen-Taylor commented 11 months ago

Thanks for the response. The nested data is a pain but I can figure that out. Do you know how to work the cursor then so I can grab all the tweets for a particular user then?

iSarabjitDhiman commented 11 months ago

Thanks for the response. The nested data is a pain but I can figure that out. Do you know how to work the cursor then so I can grab all the tweets for a particular user then?

Check out these two issues #7 and #10 for the cursor endpoint usage. Feel free to close the issue if you got the solution else let me know if there is anything else you need help with.

Allen-Taylor commented 11 months ago

Thanks Sarabjit. I saw you implemented an async/await version with the date args. I will try that and let you know.

iSarabjitDhiman commented 11 months ago

Thanks Sarabjit. I saw you implemented an async/await version with the date args. I will try that and let you know.

Yes, async/await branch has some other extra features as well, you can also check the api rate limits, find values from the nested dictionaries etc.

Allen-Taylor commented 11 months ago

So I just tried it, I'm trying to use a guest token, but it is asking me for username/password. Any thoughts? This is the async branch.

from tweeterpy import TweeterPy

twitter = TweeterPy()
twitter.generate_session()
user_tweets = twitter.get_user_tweets("elonmusk", from_date="1 August 2023")
for data in user_tweets['data']:
    print(data['content']['itemContent']['tweet_results']['result']['legacy']['created_at'])
Allen-Taylor commented 11 months ago

Any chance I can contact you in private?

iSarabjitDhiman commented 11 months ago

So I just tried it, I'm trying to use a guest token, but it is asking me for username/password. Any thoughts? This is the async branch.

from tweeterpy import TweeterPy

twitter = TweeterPy()
twitter.generate_session()
user_tweets = twitter.get_user_tweets("elonmusk", from_date="1 August 2023")
for data in user_tweets['data']:
    print(data['content']['itemContent']['tweet_results']['result']['legacy']['created_at'])

Oh yeah, I forgot to import the recent commits to the async-await branch, I will do that shortly.

iSarabjitDhiman commented 11 months ago

Any chance I can contact you in private?

iSarabjitDhiman is my username on insta/twitter/fb etc.

Allen-Taylor commented 11 months ago

Telegram?

iSarabjitDhiman commented 11 months ago

Telegram?

Yes, same username for the Telegram.