On Tuesday, February 5, 2019 at 6:14:11 PM UTC-5, fugee ohu wrote:
>
> In this regex on line 5 everything between the parentheses will be
> returned as the match array? Right now it fails with TypeError: no implicit
> conversion of nil into String
>
>
> doc=Nokogiri::HTML.parse(file)
> doc.css("script").each do |s|
> if s.text=~/skuProducts/
> js_string = s.text
> data = js_string[/\[,(.+?)\]/, 1]
> parsed_data = JSON.parse(data)
> end
> end
>
>
I'm trying to get the javascript only from this multiline string
isPurchaseLimit: "",
unit: 'pieces',
quantityNum: '8 ',
availQuantityForCustomer: '8'
};
window.runParams.warrantyServiceJson=[];
window.runParams.forcePromiseWarrantyJson={};
window.runParams.hasOverseaWarehouse="false";
var
skuProducts=[{"skuAttr":"200007763:201336100;491:200004763#145cm","skuPropIds":"201336100,200004763","skuVal":{"actSkuBulkCalPrice":"313.64",
... a lot more stuff ....
BulkCalPrice":"548.72","skuCalPrice":"577.60","skuDisplayBulkPrice":"US
$548.72","skuMultiCurrencyBulkPrice":"548.72","skuMultiCurrencyCalPrice":"577.6","skuMultiCurrencyDisplayPrice":"577.60"}}];
var GaData = {
pageType: "product",
productIds: "en32959852599",
totalValue: "US $330.15"
};
window.runParams.isFixedFreeShipping=false;
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/50bafb71-11a8-4641-b48d-15b044fbd569%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.