Sunday, May 5, 2024
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 9705  / 2 Years ago, fri, may 13, 2022, 2:14:44

Is there a simple way to retrieve someone's tweets from the command line?



The account would be public, and the command - or script, if necessary - would retrieve all or a specified number of most recent tweets to a text file, one tweet per line, without the metadata, the newest in the first line.



Without the use of API, only bash.


More From » command-line

 Answers
2

From a-close-date on, Twitter won't let you into their API without having an OAuth key. But as a workaround you can use Search API. It is RESTful, so you can use curl to retrieve search results in JSON format. For example, if you want to retrieve @java's tweets, and save it to file ~/.tweets, this line of code can be used:



curl http://search.twitter.com/search.json?q=from:java&page=1&rpp=10&callback=? >> $HOME/.tweets


And you can parse the file, using any JSON parser.



The rpp parameter is number af tweets to be retrieved. callback is javascript function to be executed on the resulting JSON. In case you're not using JavaScript with the api, you can leave it ?, but don't remove it. I will cause an error. More guidance on Search api can be found on https://dev.twitter.com/docs/api/1/get/search



There are tools to parse JSON from command line interface. Although I've never used one, I'll put some links to some resources, to help you find out the best suited tool:





And as a little note, it is quicker to use some Python or Ruby (or others).


[#34553] Saturday, May 14, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
listeerrated

Total Points: 354
Total Questions: 112
Total Answers: 100

Location: Guam
Member since Fri, Jun 18, 2021
3 Years ago
listeerrated questions
Wed, Jun 8, 22, 11:43, 2 Years ago
Wed, Mar 23, 22, 03:25, 2 Years ago
Wed, Jun 2, 21, 20:28, 3 Years ago
;