私はこの文字列を持っています
#<Fletcher::Model::Amazon alt="You Are Not a Gadget: A Manifesto (Vintage)" border="0" element="img" height="240" id="prodImage" onload="if (typeof uet == 'function') { if(typeof setCSMReq=='function'){setCSMReq('af');setCSMReq('cf');}else{uet('af');uet('cf');amznJQ.completedStage('amznJQ.AboveTheFold');} }" onmouseout="sitb_doHide('bookpopover'); return false;" onmouseover="sitb_showLayer('bookpopover'); return false;" src="http://ecx.images-amazon.com/images/I/51bpl1wA%2BaL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA240_SH20_OU01_.jpg" width="240">
私は単に src 属性にリンクが必要です:
http://ecx.images-amazon.com/images/I/51bpl1wA%2BaL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA240_SH20_OU01_.jpg"
この文字列を解析してリンクを取得するにはどうすればよいですか
以下は関連する機能のリストです
module Fletcher
module Model
class Amazon < Fletcher::Model::Base
# A regular expression for determining if a url comes from a specific service/website
def self.regexp
/amazon\.com/
end
# Parse data and look for object attributes to give to object
def parse(data)
super(data)
case doc
when Nokogiri::HTML::Document
# Get Name
self.name = doc.css("h1.parseasinTitle").first_string
# Get Description
self.description = doc.css("div#productDescriptionWrapper").first_string
# Get description from meta title if not found
self.description = doc.xpath("//meta[@name='description']/@content").first_string if description.nil?
# Get Price
parse_price(doc.css("b.priceLarge").first_string)
# Get Images
self.images = doc.xpath("//table[@class='productImageGrid']//img").attribute_array
self.image = images.first
end
end
end
end
end