关于爬虫:如何调用淘宝天猫详情API获取商品数据

108次阅读

共计 4772 个字符,预计需要花费 12 分钟才能阅读完成。

背景

在很多行业,比方商品采集、登载、数据分析行业都须要用到相干的商品接口,然而官网个别又没有凋谢这些接口,怎么办?

解决方案

js 逆向爬虫倒是很简略,然而基本扛不住大量调用,不稳固,目前支流的计划都是逆向 APP 获取数据,然而这个不是个别人又能力去做的,加上淘宝变动频繁,防爬越来越严,技术难度和老本也越来越大,没有能力的也能够找第三方 api 提供商

参考示例

{
    "code": 200,
    "msg": "success",
    "data": {
        "item_id": 638424990701,
        "title": "东成电锤电镐电钻多功能大功率冲击钻工业混凝土家用电动工具电捶",
        "category_id": "50006222",
        "root_category_id": "50020485",
        "currency": "CNY",
        "product_props": [
            {
                "根本信息": [
                    {"品牌": "东成"},
                    {"型号": "DZC1100-28"},
                    {"产地": "中国大陆"},
                    {"电源形式": "交流电"},
                    {"色彩分类": "【旗舰款带离合】【1100W 双用】规范套餐【旗舰款带离合】【1100W 双用】钻孔套餐【旗舰款带离合】【1100W 双用】开槽套餐【旗舰款带离合】【1100W 双用】穿墙套餐【业余款】【750W 单用】规范套餐【业余款】【750W 单用】钻孔套餐【业余款】【750W 单用】穿墙套餐【工业款】【750W 双用】规范套餐【工业款】【750W 双用】钻孔套餐【工业款】【750W 双用】开槽套餐【工业款】【750W 双用】穿墙套餐"},
                    {"电压": "220V"},
                    {"调速": "无"},
                    {"夹头类型": "四坑"},
                    {"工作形式": "锤钻"},
                    {"操作形式": "手持式"},
                    {"有无正反转向": "无"}
                ]
            }
        ],
        "main_imgs": [
            "https://img.alicdn.com/imgextra/i2/3319188973/O1CN01vheroL2G9gbm0YMdZ_!!3319188973-0-lubanu-s.jpg",
            "https://img.alicdn.com/imgextra/i3/3319188973/O1CN01d3LTRL2G9gYbRsbw3_!!3319188973.jpg",
            "https://img.alicdn.com/imgextra/i2/3319188973/O1CN011nE97a2G9gYZZGEUw_!!3319188973.jpg",
            "https://img.alicdn.com/imgextra/i1/3319188973/O1CN01VxPWbD2G9gYhtl6MN_!!3319188973.jpg",
            "https://img.alicdn.com/imgextra/i2/3319188973/O1CN01eAngGy2G9gaEocUIi_!!3319188973.jpg"
        ],
        "video_url": "https://cloud.video.taobao.com/play/u/3319188973/p/2/e/6/t/1/300168437152.mp4",
        "comment_count": "4448",
        "shop_info": {
            "shop_name": "东成电动工具旗舰店",
            "shop_id": "345147752",
            "shop_url": "//shop.m.taobao.com/shop/shop_index.htm?user_id=3319188973&item_id=638424990701",
            "shop_rate": [
                {
                    "title": "宝贝形容",
                    "type": "desc",
                    "score": "4.8"
                },
                {
                    "title": "卖家服务",
                    "type": "serv",
                    "score": "4.8"
                },
                {
                    "title": "物流服务",
                    "type": "post",
                    "score": "4.8"
                }
            ],
            "good_rate_percentage": "100.00%",
            "followers": "21.3 万",
            "is_tmall": true,
            "is_gold_seller": false,
            "shop_logo": "//img.alicdn.com/imgextra//b0/00/TB1Qr_JFruWBuNjSszgSuv8jVXa.jpg",
            "shop_start_time": "2017-06-05 17:33:27",
            "seller_id": "3319188973",
            "wangwang": "https://amos.alicdn.com/getcid.aw?groupid=0&s=1&cob2Un&charset=utf-8&uid=%E4%B8%9C%E6%88%90%E7%94%B5%E5%8A%A8%E5%B7%A5%E5%85%B7%E6%97%97%E8%88%B0%E5%BA%97&site=cntaobao&aBItN0"
        },
        "delivery_info": {
            "area_from": [
                "江苏省",
                "南通市"
            ],
            "area_id": "442000",
            "postage": "0"
        },
        "sku_props": [
            {
                "prop_name": "色彩分类",
                "pid": "1627207",
                "values": [
                    {
                        "name": "【旗舰款带离合】【1100W 双用】规范套餐",
                        "vid": "3232478",
                        "imageUrl": "https://img.alicdn.com/imgextra/i1/3319188973/O1CN01aQcIFs2G9gbsLGrmq_!!3319188973.jpg"
                    },
                    {
                        "name": "【旗舰款带离合】【1100W 双用】钻孔套餐",
                        "vid": "3232479",
                        "imageUrl": "https://img.alicdn.com/imgextra/i2/3319188973/O1CN01WmZnFj2G9gbsLJLdy_!!3319188973.jpg"
                    },
                    {
                        "name": "【旗舰款带离合】【1100W 双用】开槽套餐",
                        "vid": "5167321",
                        "imageUrl": "https://img.alicdn.com/imgextra/i4/3319188973/O1CN01wZDwQM2G9gbv5NkTt_!!3319188973.jpg"
                    },
                    {
                        "name": "【旗舰款带离合】【1100W 双用】穿墙套餐",
                        "vid": "28340",
                        "imageUrl": "https://img.alicdn.com/imgextra/i4/3319188973/O1CN01Ih42KZ2G9gbv5N958_!!3319188973.jpg"
                    },
                    {
                        "name": "【业余款】【750W 单用】规范套餐",
                        "vid": "3232480",
                        "imageUrl": "https://img.alicdn.com/imgextra/i3/3319188973/O1CN01vxzuCz2G9gbqnU1Rw_!!3319188973.jpg"
                    },
                    {
                        "name": "【业余款】【750W 单用】钻孔套餐",
                        "vid": "4266701",
                        "imageUrl": "https://img.alicdn.com/imgextra/i2/3319188973/O1CN01lVTzLW2G9gbv7RiGx_!!3319188973.jpg"
                    },
                    {
                        "name": "【业余款】【750W 单用】穿墙套餐",
                        "vid": "3594022",
                        "imageUrl": "https://img.alicdn.com/imgextra/i4/3319188973/O1CN01ElKG7D2G9gc3Ai4TT_!!3319188973.jpg"
                    },
                    {
                        "name": "【工业款】【750W 双用】规范套餐",
                        "vid": "80882",
                        "imageUrl": "https://img.alicdn.com/imgextra/i2/3319188973/O1CN01AUi56R2G9gbm5MqBf_!!3319188973.jpg"
                    },
                    {
                        "name": "【工业款】【750W 双用】钻孔套餐",
                        "vid": "28320",
                        "imageUrl": "https://img.alicdn.com/imgextra/i3/3319188973/O1CN01tVdlrA2G9gbzbg7A3_!!3319188973.jpg"
                    },
                    {
                        "name": "【工业款】【750W 双用】开槽套餐",
                        "vid": "28334",
                        "imageUrl": "https://img.alicdn.com/imgextra/i3/3319188973/O1CN01cd5Wal2G9gbzbh7ZZ_!!3319188973.jpg"
                    },
                    {
                        "name": "【工业款】【750W 双用】穿墙套餐",
                        "vid": "5483105",
                        "imageUrl": "https://img.alicdn.com/imgextra/i4/3319188973/O1CN01L0OU9W2G9gc2RcSRQ_!!3319188973.jpg"
                    }
                ]
            }
        ],
        "skus": [
            {
                "skuid": "4925063223553",
                "sale_price": "538",
                "stock": "1175",
                "props_ids": "1627207:3232478"
            },
            {
                "skuid": "4925063223554",
                "sale_price": "558",
                "stock": "620",
                "props_ids": "1627207:3232479"
            },
            {
                "skuid": "4925063223558",
                "sale_price": "578",
                "stock": "559",
                "props_ids": "1627207:5167321"
            },
            {
                "skuid": "4925063223552",
                "sale_price": "578",
                "stock": "109",
                "props_ids": "1627207:28340"
            },
            {
                "skuid": "4925063223555",
                "sale_price": "378",
                "stock": "1209",
                "props_ids": "1627207:3232480"
            },
            {
                "skuid": "4925063223557",
                "sale_price": "398",
                "stock": "492",
                "props_ids": "1627207:4266701"
            },
            {
                "skuid": "4925063223556",
                "sale_price": "408",
                "stock": "213",
                "props_ids": "1627207:3594022"
            },
            {
                "skuid": "4925063223560",
                "sale_price": "438",
                "stock": "1143",
                "props_ids": "1627207:80882"
            },
            {
                "skuid": "4925063223550",
                "sale_price": "488",
                "stock": "512",
                "props_ids": "1627207:28320"
            },
            {
                "skuid": "4925063223551",
                "sale_price": "508",
                "stock": "529",
                "props_ids": "1627207:28334"
            },
            {
                "skuid": "4925063223559",
                "sale_price": "508",
                "stock": "178",
                "props_ids": "1627207:5483105"
            }
        ]
    }
}

正文完
 0