开发者

how can i use ruby &/or mechanize to get a simple list of award winners?

Looking at this site here: http://www.grammy.com/nominees/search?artist=&title=&year=1958&genre=All

I can view all winners by year -- how can I scrape just the names of the winners on each page (for each year) and get them 开发者_如何学Pythonin a simple database?

thanks!


This will get you the actual names, cleaning them up a little bit and inserting them into a DB is an exercise left to you:

require 'rubygems'
require 'hpricot'
require 'open-uri'


html = open("http://www.grammy.com/nominees/search?artist=&title=&year=1958&genre=All")
doc = Hpricot(html)
doc.search("td.views-field-field-nominee-extended-value").each do |winner|
  puts winner.inner_html.strip
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜