Python code from @baekdal (find tweets you retweeted by someone else)
Posted by jpluimers on 2023/10/26
Need to try this out: [Wayback/Archive] Code from https://twitter.com/baekdal/status/1279123542144094208 and https://twitter.com/baekdal/status/1279123544052563968 (find tweets you retweeted by someone else)
Related tweets:
- [Wayback/Archive] Thomas Baekdal on Twitter: “But, wait, you say, can’t I just do that with Twitter search? Nope… because I couldn’t remember who tweeted it, only that I had retweeted it, and so if I do the search on Twitter, I get this: Twitter search doesn’t include pure retweets when searching ‘from me’.”
- [Wayback/Archive] Thomas Baekdal on Twitter: “For instance, I needed to find a tweet of CNN control operations team working from home, so now I just use my tool to search for ‘CNN’ and there it is.”
- [Wayback/Archive] Thomas Baekdal on Twitter: “But, wait, you say, can’t I just do that with Twitter search? Nope… because I couldn’t remember who tweeted it, only that I had retweeted it, and so if I do the search on Twitter, I get this: Twitter search doesn’t include pure retweets when searching ‘from me’.”
Another piece of code he wrote (found via [Wayback/Archive] @baekdal twitter api – Twitter Search / Twitter) was to get a Twitter circle: [Wayback/Archive] Thomas Baekdal on Twitter: “BTW: The code for extracting this data is really simple (using Python). Just import the Twitter API, and run thought the posts, putting each one into their own lists.”:
Via: [Wayback/Archive] Marius Popescu on Twitter: “@UScLE There is this solution using from:me but it doesn’t search your retweets, people use API scripts for that”
–jeroen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for getstatus in range(0,10): | |
| if lastid == '': | |
| statusesraw = api.GetUserTimeline(screen_name-twitteruser,count-tweetcount, include_rts=1) | |
| else: | |
| statusesraw = api.GetUserTimeline(screen_name=twitteruser,count-tweet count, include_rts=1,max_id=lastid) | |
| statuses += statusesraw | |
| lastid = statuses[-1].id | |
| for status in statusesraw: | |
| tweettxt = '' | |
| if status.retweeted: | |
| try: | |
| tweettxt tweettxt + ' ' + status.retweeted_status.text | |
| except: | |
| pass | |
| tweettxt = tweettxt + ' ' + status.text | |
| if status.quoted_status: | |
| tweettxt = tweettxt + ' ' + status.quoted_status.text | |
| if tweettxt.lower().find(twittersearch) != -1: | |
| print('————————-') | |
| print('Tweet id:', status.id) | |
| print(tweettxt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Z:\python>twitter-search.py | |
| Person: | |
| Search: cnn | |
| Twitter search: cnn | |
| ————————- | |
| Tweet id: 1274087828780187652 | |
| https://t.co/3uPw3MYVrs https://t.co/1d5A3CnNmf Daily Mail eclipses the Sun to become UK's top-selling paper https://t.co/W5EUSE5gQF | |
| ————————- | |
| Tweet id: 1270393837626822656 | |
| Behind the scenes: How @CNN's master control operations team is keeping multiple networks on the air while working… https://t.co/wlr6BrALTX RT @brianstelter: Behind the scenes: How @CNN's master control operations team is keeping multiple networks on the air while working from h… | |
| ————————- | |
| Tweet id: 1269267852906893312 | |
| Canadian Prime Minister Justin Trudeau took a knee during a Black Lives Matter demonstration in Ottawa on Friday https://t.co/SCEI7oWaWv RT @CNN: Canadian Prime Minister Justin Trudeau took a kne e during a Black Lives Matter demonstration in Ottawa on Friday https://t.co/SCEI… | |
| ————————- | |
| Tweet id: 1267599712791781384 | |
| CNNS chyron writer today is on point . https://t.co/VwYaG7QnZd RT @rgay: CNNS chyron writer today is on point . https://t.co/VwYaG7QnZd | |
| ————————- | |
| Tweet id: 1266965680169127936 | |
| What a moment on CNN. https://t.co/T9XMzXmlVb RT @oliverdarcy: What a moment on CNN. https://t.co/T9XMzXmlVb | |
| ————————- | |
| Tweet id: 1266342205490429954 | |
| CNN's @Omar Jimenez and his crew have been released from police custody. He recounts getting arrested and what happe… https://t.co/WATYCKBTTW RT @CNN: CNN's @OmarJimenez and his crew have been rel eased from police custody. He recounts getting arrested and what happened while they… | |
| ————————- | |
| Tweet id: 1266329384799088640 | |
| Live now on CNN as reported by @JohnBerman: CNN president Jeff Zucker spoke to Minnesota Gov. Tim Wola who apologiz http:llt on lubr5y6677 RT Ashbydphilling Live now on CNN poported by John |
Rate this:
Share this:
- Click to share on Mastodon (Opens in new window) Mastodon
- Click to share on Bluesky (Opens in new window) Bluesky
- Share on Tumblr
- Click to share on Reddit (Opens in new window) Reddit
- Click to share on Threads (Opens in new window) Threads
- Tweet
- Click to share on Telegram (Opens in new window) Telegram
- Click to share on Nextdoor (Opens in new window) Nextdoor
- Click to share on WhatsApp (Opens in new window) WhatsApp
- Click to print (Opens in new window) Print
- Click to email a link to a friend (Opens in new window) Email
Related
This entry was posted on 2023/10/26 at 12:00 and is filed under Development, JavaScript/ECMAScript, JSON, Python, Scripting, SocialMedia, Software Development, Twitter. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
This site uses Akismet to reduce spam. Learn how your comment data is processed.











Leave a comment