Skip to content

Instantly share code, notes, and snippets.

@siuying
Created May 31, 2009 11:53
Show Gist options
  • Save siuying/120862 to your computer and use it in GitHub Desktop.
Save siuying/120862 to your computer and use it in GitHub Desktop.
Retrieve Latest Links From Popgo, scRUBYt style
# Retrieve Latest Links From Popgo, scRUBYt style
# Sample Output: http://gist.github.com/120864
require 'rubygems'
require 'scrubyt'
require 'iconv'
popgo = Scrubyt::Extractor.define do
fetch 'http://bt.popgo.net/'
torrents "//center//table" do
file "//tr" do
details "//td[@class='name']" do
name "//a"
url "//a/@href" do
link /[a-f\d]{40}/ do
info lambda {|file_id| "http://bt.popgo.net//stats/stats_#{file_id}.html"}, :type => :script
download lambda {|file_id| "http://bt.popgo.net/down/down.php?hash=#{file_id}"}, :type => :script
end
end
end.ensure_presence_of_pattern("name")
time "//td[@class='date']"
size "//td[@class='bytes']"
source "//td[7]/a"
end.ensure_presence_of_pattern("time").ensure_presence_of_pattern("size")
end
end
puts Iconv.conv("UTF-8", "GBK", popgo.to_xml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment