懂车帝新能源汽车销量分析

懂车帝官方API接口分析和部分网页解析分析

  • 世界上最幸福的事情莫过于爬虫时F12可以找到一个官方的API接口🤡

  • ❗ 该文档仅用于学习交流,未用于其它任何途径

官方API接口分析

🔨:该接口由于官方在11月27号左右更新网址的时候已经隐藏,但是依然可以请求到数据

  • 接口地址:https://www.dongchedi.com/motor/pc/car/rank_data

  • 请求方式:GET

  • 请求参数说明:

    字段名字段说明字段类型备注是否必填
    month销量榜时间int1000:表示一年 500:表示半年 202108:表示2021年8月
    count返回的数据量int100:返回100辆车的数据
    new_energy_type新能源汽车int1:纯电动 2:插电式混动
    city城市名称varchar
    rank_data_type销量榜int11:销量榜
  • 响应示例

    1. 获取新能源汽车销量榜

      • 请求地址:https://www.dongchedi.com/motor/pc/car/rank_data?new_energy_type=1&month=1000&count=1&city=%E2%80%9C%E6%88%90%E9%83%BD%E2%80%9D&rank_data_type=11

      • 响应结果
         

        {
          "prompts": "",
          "status": 0,
          "message": "success",
          "data": {
            "head_info": {
              "title": "",
              "text": ""
            },
            "paging": {
              "count": 1,
              "has_more": true,
              "offset": 0,
              "total": 0
            },
            "list": [
              {
                "series_id": 4499,
                "series_name": "五菱宏光MINIEV",
                "image": "http://p1-dcd.byteimg.com/img/motor-img/6efbde874de291b8176fa27814b9bef3~tplv-resize:240:0.png",
                "rank": 1,
                "min_price": 2.88,
                "max_price": 4.86,
                "last_rank": -1,
                "count": 380278,
                "score": 0,
                "car_review_count": 399,
                "text": "",
                "show_trend": true,
                "descender_price": 0,
                "offline_car_ids": [
                  
                ],
                "online_car_ids": [
                  
                ],
                "series_pic_count": 2427,
                "brand_id": 39,
                "outter_detail_type": 0,
                "brand_name": "五菱汽车",
                "sub_brand_id": 198,
                "sub_brand_name": "上汽通用五菱",
                "price": "2.88-4.86万",
                "dealer_price": "2.88-4.86万",
                "has_dealer_price": true
              }
            ],
            "sells_rank_month": [
              {
                "text": "2021年11月",
                "month": 202111
              },
              {
                "text": "2021年10月",
                "month": 202110
              },
              {
                "text": "2021年09月",
                "month": 202109
              },
              {
                "text": "2021年08月",
                "month": 202108
              },
              {
                "text": "2021年07月",
                "month": 202107
              },
              {
                "text": "2021年06月",
                "month": 202106
              },
              {
                "text": "近半年",
                "month": 500
              },
              {
                "text": "近一年",
                "month": 1000
              }
            ]
          }
        }

      • 官方网页渲染对应位置

    2. 其它URL测试

懂车分页面解析

  1. 页面URL地址(以五菱宏光MINIEV为例)

    五菱宏光MINIEV_五菱宏光MINIEV_懂车帝

  2. URL地址分析

    在该页面URL中数字4499代表每款汽车的序列号,该序列号可以通过在官方API接口的请求返回的JSON数据中获得其字段名为series_id。通过该字段去构造请求URL地址,即可获得汽车的懂车分的页面信息。

    def getScore(seriesId):
        url = f"https://www.dongchedi.com/auto/series/score/{seriesId}-x-x-x-x-x-x"
        response = requestData(url, headers)
        if (response != 0):
            return response
  3. 获取懂车分信息表关键代码

    def analysisScore(seriesId, seriesName, *tableField: list):
        doc = pq(dcdReq.getScore(seriesId))
        elements = doc(".tw-h-94")
        score = []
        score.append(seriesId)
        score.append(seriesName)
        for element in elements.items():
            items = [li.text() for li in element.items('li')]
            score.append(items[1])
        if tableField:
            return dict(zip(tableField[0], score))
        else:
            return score
  • 5
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

DDddCode

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值