Ruby と Nokogiri を使用してこの Web サイトを解析しようとしています。
これが私のコードです:
require 'nokogiri'
require 'open-uri'
class StreamsController < ApplicationController
def index
end
def updateall
doc = Nokogiri::HTML(open('http://www.own3d.tv/game/League+of+Legends'))
# Grab all the Live streams from the front page.
doc.css('div#top_live .VIDEOS-1grid-box').each do |stream|
s = Stream.new
# Parse the URL.
s.url = stream.css('a.small-tn')['href']
end
end
end
# Parse the URL
ビットで、エラーが発生しますCannot convert String to Integer.
この単純なユースケースで Nokogiri を使用する方法について、私はちょっと混乱しています。
|stream|
各オブジェクト内の各リンクの href 属性を取得するにはどうすればよいですか?