有些 link 因为网络原因可能暂时不能访问,想保存下来放到下次再进行抓取
link = Nokogiri::HTML.parse(open(url)).css('a').first
link['href'] = "xxx/xxx"
TRY<一>
class MissingLink
serialize :link
end
MissingLink.create(:link => link)
missing_link = MissingLink.last
missing_link.link.class => Nokogiri::XML::Element
missing_link.link['href']
=> TypeError: wrong argument type Nokogiri::XML::Element (expected Data)
TRY<二> 使用 Marshal.dump
MissingLink.create(:link => Marshal.dump(link))
no _dump_data is defined for class Nokogiri::XML::Element
请问该怎么保存?谢谢