Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Scrape torrents on btjunkie (See related posts)

// download all .torrent links on the btjunkie frontpage
//
// more fun with mechanize @
// http://tramchase.com/scrape-myspace-youtube-torrents-for-fun-and-profit

agent = WWW::Mechanize.new
agent.get("http://btjunkie.org/")
links = agent.page.search('.tor_details tr a')
hrefs = links.map { |m| m['href'] }.select { |u| u =~ /\.torrent$/ } # just links ending in .torrent
FileUtils.mkdir_p('btjunkie-torrents') # keep it neat
hrefs.each { |torrent|
  filename = "btjunkie-torrents/#{torrent[0].split('/')[-2]}"
  puts "Saving #{torrent} as #{filename}"
  agent.get(torrent).save_as(filename)
}

Comments on this post

ishmael.moridin posts on Dec 10, 2008 at 13:31
Hello, I am a newbie to Ruby (didn't do that purposefully :P) but when I try to run this code in a new class, I get an error :

/netbeans-6.5/ruby2/jruby-1.1.4/lib/ruby/site_ruby/1.8/builtin/core_ext/symbol.rb:1:in `const_missing': uninitialized constant WWW (NameError)
        from /NetbeansProjects/TryRuby/lib/Test.rb:


Can anyone please let me know why I am getting this error ?
ishmael.moridin posts on Dec 10, 2008 at 20:43
The above error was solved when I installed rubygems1.8-dev package.
But now when I run the above code, the program executes, but no torrents are downloaded into the folder.

Any ideas ?

Thanks.

You need to create an account or log in to post comments to this site.