libのモジュールとしてnokogiriスクリプトを設定しています。また、製品フォームにURLを取得し、それをnokogiriスクリプトに渡すフィールドがあります。nokogiriモジュールが解析するデータをフォームフィールドに入力するにはどうすればよいですか。基本的に、ユーザーが製品を確認してデータベースに追加するだけで済むように、フォームに解析されたデータを入力する必要があります。
私のモジュール:
module product
def get_product
url = ""
product_page = Nokogiri::HTML(open(url))
image_url = product_page.at_xpath('/html/body/div/div[2]/div[4]/div[4]/div/div/div/div').children[3].attributes['href'].text
title_text = product_page.at_xpath('/html/body/div/div[2]/div[4]/div[4]/div[2]/div[2]/div/form/div/h1').text
description = product_page.at_xpath('//*[(@id = "SITCC_1column")]//*[contains(concat( " ", @class, " " ), concat( " ", "ItemSectionContent", " " ))]').text.strip!
curr_item_price = product_page.at_xpath('//*[(@id = "WM_PRICE")]//*[contains(concat( " ", @class, " " ), concat( " ", "camelPrice", " " ))]').text[/[0-9\.]+/]
base_item_price = product_page.at_xpath('//*[(@id = "WM_PRICE")]//*[contains(concat( " ", @class, " " ), concat( " ", "SubmapPrice", " " ))]').text[/[0-9\.]+/]
wm_item_num = url.split("/").last
id_str = "walmart_#{wm_item_num}"
end
end