Created
August 29, 2012 18:23
-
-
Save sweded/3516604 to your computer and use it in GitHub Desktop.
tweet fetchin', Bastard style
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
| require "open-uri" | |
| remote_base_url = | |
| "http://api.twitter.com/1/statuses/user_timeline.xml?count=100&screen_name=" | |
| twitter_user = "USAGov" | |
| remote_full_url = remote_base_url + twitter_user | |
| first_page = 1 | |
| last_page = 5 | |
| (first_page..last_page).each do |page_num| | |
| puts "Downloading page: " + page_num.to_s | |
| tweets = open(remote_base_url + twitter_user + "&page=" + page_num.to_s).read | |
| my_local_filename = twitter_user + "-tweets-page-" + page_num.to_s + ".xml" | |
| my_local_file = open(my_local_filename, "w") | |
| my_local_file.write(tweets) | |
| my_local_file.close | |
| sleep 5 | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment