大小存在于脚本标记中,例如,"label":"10","price"
重复使用不同的大小,如何在xpath中获得所有大小
<script type="text/javascript">
var spConfig = new Product.Config({"attributes":{"149":{"id":"149","code":"size","label":"Size","options":[{"id":"12","label":"10","price":"0","oldPrice":"0","products":["527"]},{"id":"11","label":"12","price":"0","oldPrice":"0","products":["528"]},{"id":"10","label":"14","price":"0","oldPrice":"0","products":["529"]},{"id":"14","label":"6","price":"0","oldPrice":"0","products":["525"]},{"id":"13","label":"8","price":"0","oldPrice":"0","products":["526"]}]}},"template":"$#{price}","basePrice":"621","oldPrice":"621","productId":"524","chooseText":"Choose an Option...","taxConfig":{"includeTax":true,"showIncludeTax":true,"showBothPrices":false,"defaultTax":10,"currentTax":10,"inclTaxTitle":"Incl. Tax"}});
</script>
您看到的是Javascript脚本,不能用XPath(XPath是从XML文档中选择节点的语言)或CSS选择器解析Javascript。你知道吗
但是,您可以尝试手动解析数据。此示例使用
re
模块和json
模块提取数据:印刷品:
要获取一些数据,请使用变量
json_data
作为dict:将打印:
相关问题 更多 >
编程相关推荐