Created
March 8, 2010 07:01
-
-
Save closer/324951 to your computer and use it in GitHub Desktop.
This file contains 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 "rubygems" | |
require "highline" | |
require "mechanize" | |
hl = HighLine.new | |
email = hl.ask('E-mail: ') | |
password = hl.ask('Password: '){|q| q.echo = '*'} | |
filename = ARGV.first | |
list = [] | |
a = Mechanize.new | |
a.get('http://www.tumblr.com/login') do |login_page| | |
login_page.form_with(:action => '/login') do |form| | |
form.email = email | |
form.password = password | |
end.submit | |
page_number = 1 | |
loop do | |
puts "Fetching Page #{page_number}" | |
following = a.get("/following/page/#{page_number}") | |
followers = following.search('.follower') | |
break if followers.size == 0 | |
followers.each do |follower| | |
link = follower.search('a').first['href'] | |
list << "<outline title=\"moge\" htmlUrl=\"#{link}\" type=\"rss\" xmlUrl=\"#{link}rss\" />" | |
end | |
page_number += 1 | |
sleep 0.5 | |
end | |
end | |
out <<OPML | |
<opml version="1.0"> | |
<head> | |
<title>Tumblr Following</title> | |
<dateCreated>#{DateTime.now}</dateCreated> | |
<ownerName>moge</ownerName> | |
</head> | |
<body> | |
<outline title="Subscriptions"> | |
#{list.join("\n")} | |
</outline> | |
</body></opml> | |
OPML | |
if filename | |
File.open(filename, 'w').write out | |
else | |
puts out | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment