我使用restclient和nokogiri來解析一些很好的html,但有一塊信息存儲在一個js(jquery)變量中,我需要返回,而我不是確定如何解析它。我可以使用Nokogiri來解析JavaScript塊,但我需要它的一個子集,這可能很簡單,但我不知道如何去做。我可能可以將它正則表達式,但我假設有一個簡單的方法來使用JS來請求它。ruby nokogiri restclient拖動javascript變量
@resource = RestClient.get 'http://example.com'
doc = Nokogiri::HTML(@resource)
doc.css('script').each do |script|
puts script.content
end
我試圖讓:
<script type="text/javascript">
$(function(){
//this is it
$.Somenamespace.theCurrency = 'EUR';
//a lot more stuff