Nokogiri を使用してマルチドメイン検索を行うことはできますか? 単一のドメイン/ページに対して複数の Xpath/CSS 検索を実行できるが、複数のドメインを実行できることは認識していますか?
たとえば、http://www.asus.com/Notebooks_Ultrabooks/S56CA/#specificationsとhttp://www.asus.com/Notebooks_Ultrabooks/ASUS_TAICHI_21/#specificationsをスクレイピングしたい
マイコード
require 'nokogiri'
require 'open-uri'
require 'spreadsheet'
doc = Nokogiri::HTML(open("http://www.asus.com/Notebooks_Ultrabooks/ASUS_TAICHI_21/#specifications"))
#Grab our product specifications
data = doc.css('div#specifications div#spec-area ul.product-spec li')
#Modify our data
lines = data.map(&:text)
#Create the Spreadsheet
Spreadsheet.client_encoding = 'UTF-8'
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet
sheet1.name = 'My First Worksheet'
#Output our data to the Spreadsheet
lines.each.with_index do |line, i|
sheet1[i, 0] = line
end
book.write 'C:/Users/Barry/Desktop/output.xls'