question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get only native retweets with a search filter?

See original GitHub issue

I am trying to get all the tweets (and their native retweets) tweeted by a new media account. I want to measure the impact of their tweets in time. I expect to produce this type of list of tweets to make data visualizations

author text timestamp
@newsmedia Original tweet by newsmedia -
@oneuser RT @newsmedia Original tweet by newsmedia -
@otheruser RT @newsmedia Original tweet by newsmedia -
@newsmedia Another Original tweet by newsmedia -
@onemoreuser RT @newsmedia Another Original tweet by newsmedia -

So I’d need to filter to have the original tweets by the news media and the “nativeretweet” of those tweets

This is the query I am trying, that is not yet ready. I’d still need to add the filter to return only native retweets (like -filter:nativeretweets) and include the original tweets by the news media user:

twarc2 search 'url:"twitter.com/eldiarioes"' --exclude-replies --start-time 2018-03-21T00:00:01 --end-time 2018-03-21T23:59:59 --archive > 2018-03-21_eldiario_rts.json

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
SamHamescommented, Feb 3, 2022

In that case, you would get the second - Twitter applies the AND operator first as specified in the docs: https://developer.twitter.com/en/docs/twitter-api/tweets/search/integrate/build-a-query#order-of-operations

If in doubt it’s best to throw in brackets to make it explicit and more readable.

(This is also something that changed from V1.1 to V2, the OR used to have priority)

1reaction
numerotecacommented, Feb 8, 2022

Yes, I managed to do it with your advice. Thanks again!

For the record, I used these scripts, working just with twarc2 counts, to download the amount of tweets of every news media I am studying. I realized I didn’t need the real tweets (though in parallel I am analyzing the tweets to check these results).

All tweets by news media twarc2 counts --archive '(from:elconfidencial)' --start-time 2018-03-20T00:00:00 --end-time 2018-05-01T23:59:59 --csv --granularity day > newsmedia.csv

All tweets by news media and search topic twarc2 counts --archive '(from:elconfidencial cifuentes)' --start-time 2018-03-20T00:00:00 --end-time 2018-05-01T23:59:59 --csv --granularity day > newsmedia_topic.csv

All tweets by news media and their RT twarc2 counts --archive '(from:elconfidencial OR retweets_of:elconfidencial)' --start-time 2018-03-20T00:00:00 --end-time 2018-05-01T23:59:59 --csv --granularity day > newsmedia-RT.csv

All tweets by news media and their RT and search topic twarc2 counts --archive '( (from:elconfidencial OR retweets_of:elconfidencial) cifuentes)' --start-time 2018-03-20T00:00:00 --end-time 2018-05-01T23:59:59 --csv --granularity day > newsmedia-RT_topic.csv

Then with this other R script I processed all the data and generated visualizations like these ones:

For 1 news media: cifuentes-00-4panel_cifuentes-elconfidencial

cifuentes-01-n-tweets-only-newsmedia_cifuentes-elconfidencial

Now I calculate the percentage for this news media in two ways:

  • tweets by @newsmedia about the search topic from the total of tweets that the @newsmedia tweeted each day
  • tweets by @newsmedia and their RT about the search topic from the total of tweets and RT that the @newsmedia got each day

cifuentes-03-percent_cifuentes-elconfidencial

All the news media together:

cifuentes-news-media-tweets_from-total_twarc

cifuentes-news-media-tweets-twarc_colored

cifuentes-news-media-tweets-with-RT-twarc_colored

I also replicated these analysis by the hour and calculated their correlations.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Twitter Advanced Search - Complete guide on how to use it
On twitter advanced search, to filter tweets by date we will use the commands SINCE ... To search someone's tweets you just have...
Read more >
Use Twitter Advanced search to find retweets made by a ...
As @AlexVong noted in the comments, you can find the new referential retweets by using: from:username include:nativeretweets filter: ...
Read more >
Luca Hammer on Twitter: "By combining it with "filter:retweets ...
By combining it with "filter:retweets", you can search only through Retweets. Example: "filter:retweets include:nativeretweets from:luca" https://twitter.com/ ...
Read more >
How to see only someone's original tweets on Twitter, filtering ...
Simply scroll down to your older tweets and click the retweet button as usual, selecting to either quote yourself - an opportunity to...
Read more >
[QUESTION] apply "filter:nativeretweets" to search function #492
You are getting nothing because Twitter does not return retweets. ... In general, your command is correct! I'll add this feature as soon...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found