猿问

如何在 webscraping 中使用 python regex 提取脚本的值?

我正在尝试学习如何使用正则表达式使用 python 提取值。这是脚本,如何获取销售价格、卖家名称和 skuId

<script>

define('app/pc', ['//laz-g-cdn.alicdn.com/lzdfe/pdp-platform/0.1.8/pc.js'], function(app) {

try {

    app.run( {

        "data": {

            "root": {

                "fields": {"skuInfos": {

                        "0": {

                            "categoryId":"8711", "dataLayer": {

                                "pdt_category":["Mother & Baby", "Feeding", "Milk Formula", "Follow On (6 - 12 mnths)"], "pagetype":"pdp", "pdt_discount":"-8%", "pdt_photo":"//laz-img-sg.alicdn.com/original/6bdf9b4b759b97f57b438a605f0e37e7.jpg", "v_voya":1, "brand_name":"Dumex", "brand_id":"30360", "pdt_sku":153105871, "core": {

                                    "country": "SG", "layoutType": "desktop", "language": "en", "currencyCode": "SGD"

                                }

                                , "seller_name":"Dumex", "pdt_simplesku":191142180, "pdt_name":"Dumex Mamil Gold Stage 2 Follow On Baby Milk Formula (850g)", "page": {

                                    "regCategoryId": "180101030000", "xParams": "_p_typ=pdp&_p_ispdp=1&_p_item=DU741TBAATAO7DSGAMZ-61110782&_p_prod=153105871&_p_sku=191142180&_p_slr=100047849"

                                }

                                , "supplier_id":100047849, "pdt_price":"47.9"

                            }

                            , "image":"//laz-img-sg.alicdn.com/original/6bdf9b4b759b97f57b438a605f0e37e7.jpg", "inWishlist":false, "itemId":"153105871", "operation": {

                                "operationWeight": 6, "text": "Add to Cart", "type": "default"

                            }

</script>


POPMUISE
浏览 143回答 1
1回答
随时随地看视频慕课网APP

相关分类

Python
我要回答