| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2026-2-13 |
| 在线时间 | 13 小时 |
WG后援团 此人已死 有事烧纸
- 梦石
- 0
- 星屑
- 75
- 在线时间
- 13 小时
- 注册时间
- 2008-1-12
- 回帖
- 1650

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
#...
text = lambda { |x| unicode.iconv(x.inner_text) }
link = lambda { |x| x[:href] }
whats = open(WHATS) { |f| Hpricot(f) }
singers = (whats/"/html/body/table[3]/tr/td/a[2]").collect &text
songs = (whats/"/html/body/table[3]/tr/td/a[1]")
song_names = songs.collect &text
song_urls = songs.collect &link
File.open("top100_list.txt", "w") do |os|
song_urls.each_with_index do |song, i|
#exit if i == 20
os << "#{i+1}. #{singers} - #{song_names}\n"
links = open(song){ |f| Hpricot(f) }
urls = (links/"/html/body/div[2]/table[2]/tr/td[2]/a[1]").collect &link
urls[0..1].each do |url|
page = Net::HTTP.get(URI.parse(URI.encode(url)))
os << decode(unicode.iconv($1)) << "\n" if page =~ /var .="(.*)",J/
end
os << "\n"
end
end
不要根据里面出现song就以为返回的是歌曲,的确是歌曲,但是是什么样的歌曲呢? |
|