Created
May 31, 2009 11:53
-
-
Save siuying/120862 to your computer and use it in GitHub Desktop.
Retrieve Latest Links From Popgo, scRUBYt style
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
# 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