1
我試圖用機械+ nokogiri解析腳本標記內的值。這是就我所能得到的用nokogiri解析javascript函數元素
1.9.3-p125 :107 > agent.page.search("script")[7]
=> #<Nokogiri::XML::Element:0x3ff1e10f3ff8 name="script" attributes=
[#<Nokogiri::XML::Attr:0x3ff1e10f3f80 name="type" value="text/javascript">] children=
[#<Nokogiri::XML::CDATA:0x3ff1e10f39b8 "countdownFactory.create('47884', '1333724400000', '');countdownFactory.create('48436', '1333638000000', '');countdownFactory.create('46085', '1333627200000', '');countdownFactory.create('48151', '1333551600000', '');countdownFactory.create('48211', '1333638000000', '');countdownFactory.create('48511', '1333551600000', '');countdownFactory.create('48513', '1333551600000', '');countdownFactory.create('48482', '1333551600000', '');countdownFactory.create('48439', '1333551600000', '');countdownFactory.create('48299', '1333551600000', '');countdownFactory.create('48272', '1333670400000', '');countdownFactory.create('46371', '1333638000000', '');countdownFactory.create('48254', '1333724400000', '');countdownFactory.create('46086', '1333638000000', '');countdownFactory.create('48317', '1333638000000', '');countdownFactory.create('48435', '1333724400000', '');countdownFactory.create('47223', '1334059200000', '');countdownFactory.create('48234', '1333972800000', '');countdownFactory.create('48407', '1333638000000', '');countdownFactory.create('48429', '1333638000000', '');countdownFactory.create('48212', '1333638000000', '');countdownFactory.create('48275', '1333551600000', '');countdownFactory.create('48205', '1333551600000', '');countdownFactory.create('48414', '1333886400000', '');countdownFactory.create('48185', '1333713600000', '');countdownFactory.create('48215', '1333540800000', '');countdownFactory.create('47636', '1333638000000', '');">]
如何將所有countdownFactory.create元素都變爲散列?謝謝!
謝謝,我也落得只是正則表達式解析它。現在運作得很好。 :) – LeoAlmighty 2012-04-04 20:18:33