这是包含所需数据的脚本在html页面上的样子:
u'{ displayName:"iPhone 5 16GB Black", productNameUrl:"apple-iphone-5-16gb-black-and-slate", _default:"true", priority:"1", paymMinPrice:"9.99", paymMinMrc:"46.00", paymMinContractLength:"24 Months", pagmMinPrice:"", paygMinMrc:"", paygMinContractLength:"", paymentTypeUrl:"pay-monthly" } handset.imgURLimage_reg_url //handset.contactless contactless handset.colours colours handset.compare compare handset.exclusive exclusive handset.dmMessage dmMessage handset.ctaButton ctaButton ifhsetDispArr["iphone-5"] ! null { handDispObj hsetDispArr["iphone-5"] handDispObj.handsets.pushhandset } else { handsets.pushhandset handDispObj {productDispPFUrl:"iphone-5-group", productPFUrl:"apple-iphone-5-16gb-black-and-slate", manufacturerName:"Apple", productDispName:"iPhone 5", handsets:handsets} hsetDispKeys.push"iphone-5" } handDispObj.handsets.sortfunctionh1,h2{ifh1._default "true"{return false}else ifh2._default "true"{return true}else{return h1.priority > h2.priority}} hsetDispArr["iphone-5"] handDispObj var handDispObj {}'
我需要从这个脚本中提取productNameUrl
(顶部的第二个标记)标记下的信息。有人能告诉我怎么做吗
因为这个脚本不是标准的JSON格式,所以我不能同时使用JSON.loads
假设您的信息字符串存储在“info”中
全部只使用split函数
相关问题 更多 >
编程相关推荐