最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】汽车之家车型车系数据:抓取车型的详细参数配置

参数 crifan 4613浏览 0评论
折腾:
【未解决】用Python爬取汽车之家的车型车系详细数据
期间,希望继续去支持:详细参数配置的抓取
类似于这种:
对此:
要去搞清楚:从哪里入手可以打开进入这个页面
以及,是否有比这个页面更好的抓取的地方,如果有,就用新的页面去抓取这些参数
因为记得好像spec页面,是不是更好抓取
分析了一下,貌似一样的https://www.autohome.com.cn/3170/#levelsource=000000000_0&pvareaid=101594
-》
-》
【奥迪A3 2020款 改款 Sportback 35 TFSI 进取型 国VI参数配置表】价格单_奥迪_汽车之家
还是会跳到这个页面
所以还是这个入口,没其他更好的入口
然后就是 分析如何调试,以及去写代码实现
且研究发现:
从参数配置 点击进来后,第一列 ,就是我们要抓取的车型的参数
其他列是其他型号的。
所以就可以,想办法从之前的 车型的spec的url
找到或组合出 此处的
config/spec/
页面
https://car.autohome.com.cn/config/spec/43593.html
然后再去打开
去试试
调试发现
html中是可以直接返回json数据的:
就是数据非常非常多。
然后此处暂时只关注:第一个 基本参数
不过也发现个问题
貌似此处都是:燃油车
(从需求中看出)对于电动车 貌似有另外的字段?
去研究看看
找个电动车的看看
找了个:
【奥迪A6L新能源】_奥迪A6L新能源报价_图片_汽车之家
-》
【图】奥迪A6L新能源 2020款 55 TFSI e quattro报价_图片_奥迪_汽车之家
-》
【奥迪A6L新能源 2020款 55 TFSI e quattro参数配置表】价格单_奥迪_汽车之家
->结果是:字段一样
-》是 插电式混合动力
-》看来要是 纯电的 字段才不同?
【奥迪Q2L e-tron】奥迪_奥迪Q2L e-tron报价_奥迪Q2L e-tron图片_汽车之家
-》
【图】奥迪Q2L e-tron 2019款 Q2L e-tron 纯电智酷型报价_图片_奥迪_汽车之家
-》
【奥迪Q2L e-tron 2019款 Q2L e-tron 纯电智酷型参数配置表】价格单_奥迪_汽车之家
的确是部分字段不同。

然后就可以去分析和写代码了。

然后发现:
【规避解决】汽车之家配置页面无法直接获取到文字数据
最后这部分代码是:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
    @catch_status_code_error
    def carConfigSpecCallback(self, response):
        print("in carConfigSpecCallback")
        curCarModelDict = response.save
        print("curCarModelDict=%s" % curCarModelDict)
        carModelDict = copy.deepcopy(curCarModelDict)
 
 
        configSpecHtml = response.text
        # print("configSpecHtml=%s" % configSpecHtml)
        # print("")
 
 
        """
        <table class="tbcs" id="tab_0" style="width: 932px;">
            <tbody>
                <tr>
                    <th class="cstitle" show="1" pid="tab_0" id="nav_meto_0" colspan="5">
                    <h3><span>基本参数</span></h3>
                    </th>
                </tr>
                <tr data-pnid="1_-1" id="tr_0">
        """
        tbodyDoc = response.doc("table[id='tab_0'] tbody")
        print("tbodyDoc=%s" % tbodyDoc)
 
 
        if tbodyDoc:
            carEnergyType = self.getItemFirstValue(tbodyDoc, 2) # 纯电动 / 汽油 / 插电式混合动力
            carModelDict["carEnergyType"] = carEnergyType
 
 
            if carEnergyType == "汽油":
                self.processGasolineCar(tbodyDoc, carModelDict)
            elif carEnergyType == "纯电动":
                self.processPureElectricCar(tbodyDoc, carModelDict)
            elif carEnergyType == "插电式混合动力":
                self.processPhevCar(tbodyDoc, carModelDict)
            elif carEnergyType == "油电混合":
                self.processHevCar(tbodyDoc, carModelDict)
            else:
                errMsg = "TODO: add support %s!" % carEnergyType
                raise Exception(errMsg)
        else:
            self.saveSingleResult(carModelDict)
 
 
    def processGasolineCar(self, tbodyDoc, carModelDict):
        # 汽油
 
 
 
 
        # 环保标准
        carModelEnvStandard = self.getItemFirstValue(tbodyDoc, 3) # 国VI
        carModelDict["carModelEnvStandard"] = carModelEnvStandard
 
 
        # 上市时间
        carModelReleaseTime = self.getItemFirstValue(tbodyDoc, 4) # 2020.04
        carModelDict["carModelReleaseTime"] = carModelReleaseTime
 
 
        # 最大功率(kW)
        carModelMaxPower = self.getItemFirstValue(tbodyDoc, 5) # 110
        carModelDict["carModelMaxPower"] = carModelMaxPower
 
 
        # 最大扭矩(N·m)
        carModelMaxTorque = self.getItemFirstValue(tbodyDoc, 6) # 250
        carModelDict["carModelMaxTorque"] = carModelMaxTorque
 
 
        # 发动机
        carModelEngine = self.getItemFirstValue(tbodyDoc, 7) # 1.4T 150马力 L4
        carModelDict["carModelEngine"] = carModelEngine
 
 
        # 变速箱
        carModelGearBox = self.getItemFirstValue(tbodyDoc, 8) # 7挡双离合
        carModelDict["carModelGearBox"] = carModelGearBox
 
 
        # 长*宽*高(mm)
        carModelSize = self.getItemFirstValue(tbodyDoc, 9) # 4312*1785*1426
        carModelDict["carModelSize"] = carModelSize
 
 
        # 车身结构
        carModelBodyStructure = self.getItemFirstValue(tbodyDoc, 10) # 5门5座两厢车
        carModelDict["carModelBodyStructure"] = carModelBodyStructure
 
 
        # 最高车速(km/h)
        carModelMaxSpeed = self.getItemFirstValue(tbodyDoc, 11) # 200
        carModelDict["carModelMaxSpeed"] = carModelMaxSpeed
 
 
        # 官方0-100km/h加速(s)
        carModelOfficialSpeedupTime = self.getItemFirstValue(tbodyDoc, 12) # 8.4
        carModelDict["carModelOfficialSpeedupTime"] = carModelOfficialSpeedupTime
 
 
        # 实测0-100km/h加速(s)
        carModelActualTestSpeedupTime = self.getItemFirstValue(tbodyDoc, 13) # -
        carModelDict["carModelActualTestSpeedupTime"] = carModelActualTestSpeedupTime
 
 
        # 实测100-0km/h制动(m)
        carModelActualTestBrakeDistance = self.getItemFirstValue(tbodyDoc, 14) # -
        carModelDict["carModelActualTestBrakeDistance"] = carModelActualTestBrakeDistance
 
 
        # 工信部综合油耗(L/100km)
        carModelMiitCompositeFuelConsumption = self.getItemFirstValue(tbodyDoc, 15) # 5.8
        carModelDict["carModelMiitCompositeFuelConsumption"] = carModelMiitCompositeFuelConsumption
 
 
        # 实测油耗(L/100km)
        carModelActualFuelConsumption = self.getItemFirstValue(tbodyDoc, 16) # -
        carModelDict["carModelActualFuelConsumption"] = carModelActualFuelConsumption
 
 
        # 整车质保
        firstDivDoc = self.getItemFirstValue(tbodyDoc, 17, isRespDoc=True)
        print("firstDivDoc=%s" % firstDivDoc)
        carModelWholeWarranty = self.extractWholeWarranty(firstDivDoc) # 三年或10万公里
        carModelDict["carModelWholeWarranty"] = carModelWholeWarranty
 
 
        self.saveSingleResult(carModelDict)
 
 
    def processPureElectricCar(self, tbodyDoc, carModelDict):
        # 纯电动
 
 
 
 
        # 上市时间
        carModelReleaseTime = self.getItemFirstValue(tbodyDoc, 3) # 2019.11
        carModelDict["carModelReleaseTime"] = carModelReleaseTime
 
 
        # 工信部纯电续航里程(km)
        carModelMiitEnduranceMileagePureElectric = self.getItemFirstValue(tbodyDoc, 4) # 265
        carModelDict["carModelMiitEnduranceMileagePureElectric"] = carModelMiitEnduranceMileagePureElectric
 
 
        # 快充时间(小时)
        carModelQuickCharge = self.getItemFirstValue(tbodyDoc, 5) # 0.6
        carModelDict["carModelQuickCharge"] = carModelQuickCharge
 
 
        # 慢充时间(小时)
        carModelSlowCharge = self.getItemFirstValue(tbodyDoc, 6) # 17
        carModelDict["carModelSlowCharge"] = carModelSlowCharge
 
 
        # 快充电量百分比
        carModelQuickChargePercent = self.getItemFirstValue(tbodyDoc, 7) # 80
        carModelDict["carModelQuickChargePercent"] = carModelQuickChargePercent
 
 
        # 最大功率(kW)
        carModelMaxPower = self.getItemFirstValue(tbodyDoc, 8) # 100
        carModelDict["carModelMaxPower"] = carModelMaxPower
 
 
        # 最大扭矩(N·m)
        carModelMaxTorque = self.getItemFirstValue(tbodyDoc, 9) # 290
        carModelDict["carModelMaxTorque"] = carModelMaxTorque
 
 
        # 电动机(Ps)
        carModelHorsePowerElectric = self.getItemFirstValue(tbodyDoc, 10) # 136
        carModelDict["carModelHorsePowerElectric"] = carModelHorsePowerElectric
 
 
        # 长*宽*高(mm)
        carModelSize = self.getItemFirstValue(tbodyDoc, 11) # 4237*1785*1548
        carModelDict["carModelSize"] = carModelSize
 
 
        # 车身结构
        carModelBodyStructure = self.getItemFirstValue(tbodyDoc, 12) # 5门5座SUV
        carModelDict["carModelBodyStructure"] = carModelBodyStructure
 
 
        # 最高车速(km/h)
        carModelMaxSpeed = self.getItemFirstValue(tbodyDoc, 13) # 150
        carModelDict["carModelMaxSpeed"] = carModelMaxSpeed
 
 
        # 官方0-100km/h加速(s)
        carModelOfficialSpeedupTime = self.getItemFirstValue(tbodyDoc, 14) # -
        carModelDict["carModelOfficialSpeedupTime"] = carModelOfficialSpeedupTime
 
 
        # 实测0-100km/h加速(s)
        carModelActualTestSpeedupTime = self.getItemFirstValue(tbodyDoc, 15) # -
        carModelDict["carModelActualTestSpeedupTime"] = carModelActualTestSpeedupTime
 
 
        # 实测100-0km/h制动(m)
        carModelActualTestBrakeDistance = self.getItemFirstValue(tbodyDoc, 16) # -
        carModelDict["carModelActualTestBrakeDistance"] = carModelActualTestBrakeDistance
 
 
        # 实测续航里程(km)
        carModelActualTestEnduranceMileage = self.getItemFirstValue(tbodyDoc, 17) # -
        carModelDict["carModelActualTestEnduranceMileage"] = carModelActualTestEnduranceMileage
 
 
        # 实测快充时间(小时)
        carModelActualTestQuickCharge = self.getItemFirstValue(tbodyDoc, 18) # -
        carModelDict["carModelActualTestQuickCharge"] = carModelActualTestQuickCharge
 
 
        # 实测慢充时间(小时)
        carModelActualTestSlowCharge = self.getItemFirstValue(tbodyDoc, 19) # -
        carModelDict["carModelActualTestSlowCharge"] = carModelActualTestSlowCharge
 
 
        # 整车质保
        firstDivDoc = self.getItemFirstValue(tbodyDoc, 20, isRespDoc=True)
        carModelWholeWarranty = self.extractWholeWarranty(firstDivDoc) # 三年或10万公里
        carModelDict["carModelWholeWarranty"] = carModelWholeWarranty
 
 
        self.saveSingleResult(carModelDict)
 
 
    def processPhevCar(self, tbodyDoc, carModelDict):
        # 插电式混合动力 = PHEV = Plug-in Hybrid Electric vehicle
 
 
 
 
        # 环保标准
        carModelEnvStandard = self.getItemFirstValue(tbodyDoc, 3) # 国V
        carModelDict["carModelEnvStandard"] = carModelEnvStandard
 
 
        # 上市时间
        carModelReleaseTime = self.getItemFirstValue(tbodyDoc, 4) # 2018.11
        carModelDict["carModelReleaseTime"] = carModelReleaseTime
 
 
        # 工信部纯电续航里程(km)
        carModelMiitEnduranceMileagePureElectric = self.getItemFirstValue(tbodyDoc, 5) # 56
        carModelDict["carModelMiitEnduranceMileagePureElectric"] = carModelMiitEnduranceMileagePureElectric
 
 
        # 快充时间(小时)
        carModelQuickCharge = self.getItemFirstValue(tbodyDoc, 6) # 2.5
        carModelDict["carModelQuickCharge"] = carModelQuickCharge
 
 
        # 慢充时间(小时)
        carModelSlowCharge = self.getItemFirstValue(tbodyDoc, 7) # 10.8
        carModelDict["carModelSlowCharge"] = carModelSlowCharge
 
 
        # 快充电量百分比
        carModelQuickChargePercent = self.getItemFirstValue(tbodyDoc, 8) # -
        carModelDict["carModelQuickChargePercent"] = carModelQuickChargePercent
 
 
        # 最大功率(kW)
        carModelMaxPower = self.getItemFirstValue(tbodyDoc, 9) # 270
        carModelDict["carModelMaxPower"] = carModelMaxPower
 
 
        # 最大扭矩(N·m)
        carModelMaxTorque = self.getItemFirstValue(tbodyDoc, 10) # 700
        carModelDict["carModelMaxTorque"] = carModelMaxTorque
 
 
        # 发动机
        carModelEngine = self.getItemFirstValue(tbodyDoc, 11) # 2.0T 252马力 L4
        carModelDict["carModelEngine"] = carModelEngine
 
 
        # 电动机(Ps)
        carModelHorsePowerElectric = self.getItemFirstValue(tbodyDoc, 12) # 128
        carModelDict["carModelHorsePowerElectric"] = carModelHorsePowerElectric
 
 
        # 变速箱
        carModelGearBox = self.getItemFirstValue(tbodyDoc, 13) # 8挡手自一体
        carModelDict["carModelGearBox"] = carModelGearBox
 
 
        # 长*宽*高(mm)
        carModelSize = self.getItemFirstValue(tbodyDoc, 14) # 5071*1968*1716
        carModelDict["carModelSize"] = carModelSize
 
 
        # 车身结构
        carModelBodyStructure = self.getItemFirstValue(tbodyDoc, 15) # 5门5座SUV
        carModelDict["carModelBodyStructure"] = carModelBodyStructure
 
 
        # 最高车速(km/h)
        carModelMaxSpeed = self.getItemFirstValue(tbodyDoc, 16) # 228
        carModelDict["carModelMaxSpeed"] = carModelMaxSpeed
 
 
        # 官方0-100km/h加速(s)
        carModelOfficialSpeedupTime = self.getItemFirstValue(tbodyDoc, 17) # 5.9
        carModelDict["carModelOfficialSpeedupTime"] = carModelOfficialSpeedupTime
 
 
        # 实测0-100km/h加速(s)
        carModelActualTestSpeedupTime = self.getItemFirstValue(tbodyDoc, 18) # -
        carModelDict["carModelActualTestSpeedupTime"] = carModelActualTestSpeedupTime
 
 
        # 实测100-0km/h制动(m)
        carModelActualTestBrakeDistance = self.getItemFirstValue(tbodyDoc, 19) # -
        carModelDict["carModelActualTestBrakeDistance"] = carModelActualTestBrakeDistance
 
 
        # 实测续航里程(km)
        carModelActualTestEnduranceMileage = self.getItemFirstValue(tbodyDoc, 20) # -
        carModelDict["carModelActualTestEnduranceMileage"] = carModelActualTestEnduranceMileage
 
 
        # 实测快充时间(小时)
        carModelActualTestQuickCharge = self.getItemFirstValue(tbodyDoc, 21) # -
        carModelDict["carModelActualTestQuickCharge"] = carModelActualTestQuickCharge
 
 
        # 实测慢充时间(小时)
        carModelActualTestSlowCharge = self.getItemFirstValue(tbodyDoc, 22) # -
        carModelDict["carModelActualTestSlowCharge"] = carModelActualTestSlowCharge
 
 
        # 工信部综合油耗(L/100km)
        carModelMiitCompositeFuelConsumption = self.getItemFirstValue(tbodyDoc, 23) # 2.4
        carModelDict["carModelMiitCompositeFuelConsumption"] = carModelMiitCompositeFuelConsumption
 
 
        # 实测油耗(L/100km)
        carModelActualFuelConsumption = self.getItemFirstValue(tbodyDoc, 24) # -
        carModelDict["carModelActualFuelConsumption"] = carModelActualFuelConsumption
 
 
        # 整车质保
        firstDivDoc = self.getItemFirstValue(tbodyDoc, 25, isRespDoc=True)
        carModelWholeWarranty = self.extractWholeWarranty(firstDivDoc) # 三年或10万公里
        carModelDict["carModelWholeWarranty"] = carModelWholeWarranty
 
 
        self.saveSingleResult(carModelDict)
 
 
    def processHevCar(self, tbodyDoc, carModelDict):
        # 混合电动汽车=HEV=Hybrid Electric Vehicle
 
 
 
 
        # 环保标准
        carModelEnvStandard = self.getItemFirstValue(tbodyDoc, 3) # 国IV(国V)
        carModelDict["carModelEnvStandard"] = carModelEnvStandard
 
 
        # 上市时间
        carModelReleaseTime = self.getItemFirstValue(tbodyDoc, 4) # 2018.08
        carModelDict["carModelReleaseTime"] = carModelReleaseTime
 
 
        # 最大功率(kW)
        carModelMaxPower = self.getItemFirstValue(tbodyDoc, 5) # 100
        carModelDict["carModelMaxPower"] = carModelMaxPower
 
 
        # 最大扭矩(N·m)
        carModelMaxTorque = self.getItemFirstValue(tbodyDoc, 6) # -
        carModelDict["carModelMaxTorque"] = carModelMaxTorque
 
 
        # 发动机
        carModelEngine = self.getItemFirstValue(tbodyDoc, 7) # 1.8L 99马力 L4
        carModelDict["carModelEngine"] = carModelEngine
 
 
        # 电动机(Ps)
        carModelHorsePowerElectric = self.getItemFirstValue(tbodyDoc, 8) # 82
        carModelDict["carModelHorsePowerElectric"] = carModelHorsePowerElectric
 
 
        # 变速箱
        carModelGearBox = self.getItemFirstValue(tbodyDoc, 9) # E-CVT无级变速
        carModelDict["carModelGearBox"] = carModelGearBox
 
 
        # 长*宽*高(mm)
        carModelSize = self.getItemFirstValue(tbodyDoc, 10) # 4360*1765*1455
        carModelDict["carModelSize"] = carModelSize
 
 
        # 车身结构
        carModelBodyStructure = self.getItemFirstValue(tbodyDoc, 11) # 5门5座SUV
        carModelDict["carModelBodyStructure"] = carModelBodyStructure
 
 
        # 最高车速(km/h)
        carModelMaxSpeed = self.getItemFirstValue(tbodyDoc, 12) # -
        carModelDict["carModelMaxSpeed"] = carModelMaxSpeed
 
 
        # 官方0-100km/h加速(s)
        carModelOfficialSpeedupTime = self.getItemFirstValue(tbodyDoc, 13) # -
        carModelDict["carModelOfficialSpeedupTime"] = carModelOfficialSpeedupTime
 
 
        # 实测0-100km/h加速(s)
        carModelActualTestSpeedupTime = self.getItemFirstValue(tbodyDoc, 14) # -
        carModelDict["carModelActualTestSpeedupTime"] = carModelActualTestSpeedupTime
 
 
        # 实测100-0km/h制动(m)
        carModelActualTestBrakeDistance = self.getItemFirstValue(tbodyDoc, 15) # -
        carModelDict["carModelActualTestBrakeDistance"] = carModelActualTestBrakeDistance
 
 
        # 工信部综合油耗(L/100km)
        carModelMiitCompositeFuelConsumption = self.getItemFirstValue(tbodyDoc, 16) # 4.6
        carModelDict["carModelMiitCompositeFuelConsumption"] = carModelMiitCompositeFuelConsumption
 
 
        # 实测油耗(L/100km)
        carModelActualFuelConsumption = self.getItemFirstValue(tbodyDoc, 17) # -
        carModelDict["carModelActualFuelConsumption"] = carModelActualFuelConsumption
 
 
        # 整车质保
        firstDivDoc = self.getItemFirstValue(tbodyDoc, 18, isRespDoc=True)
        carModelWholeWarranty = self.extractWholeWarranty(firstDivDoc) # 六年或15万公里
        carModelDict["carModelWholeWarranty"] = carModelWholeWarranty
 
 
        self.saveSingleResult(carModelDict)
 
 
    def processSingleResult(self, curCarModelDict):
        print("in processSingleResult")
        self.processCarSpecConfig(curCarModelDict)
 
 
        # self.saveSingleResult(curCarModelDict)
 
 
    def saveSingleResult(self, curCarModelDict):
        carModelDict = copy.deepcopy(curCarModelDict)
        # print("before filter: carModelDict=%s" % carModelDict)
        # process
        for curKey, curValue in carModelDict.items():
            print("curKey=%s, curValue=%s" % (curKey, curValue))
            if curValue is None:
                carModelDict[curKey] = ""
            elif curValue == "-":
                # '-' -> ''
                carModelDict[curKey] = ""
            elif "暂无" in curValue:
                # '暂无 暂无 暂无', '暂无' -> ''
                carModelDict[curKey] = ""
        # print("after filter: carModelDict=%s" % carModelDict)
 
 
        carAllKeyList = [
            "carBrandName",
            "carBrandId",
            "carBrandLogoUrl",
            "carMerchantName",
            "carMerchantUrl",
            "carSeriesId",
            "carSeriesName",
            "carSeriesUrl",
            "carSeriesMsrp",
            "carSeriesMsrpUrl",
            "carSeriesMainImgUrl",
            "carSeriesMinPrice",
            "carSeriesMaxPrice",
            "carSeriesLevelName",
            "carSeriesLevelId",
            "carModelName",
            "carModelSpecUrl",
            "carModelSpecId",
            "carModelMsrp",
            "carModelYear",
            "carModelGearBox",
            "carModelDriveType",
            "carModelBodyStructure",
            "carModelEngine",
            "carModelGroupName",
            "carModelDataSift2",
            "carModelDataSift3",
            "carModelDataSift4",
            "carEnergyType",
            "carModelEnvStandard",
            "carModelReleaseTime",
            "carModelMaxPower",
            "carModelMaxTorque",
            "carModelSize",
            "carModelMaxSpeed",
            "carModelOfficialSpeedupTime",
            "carModelActualTestSpeedupTime",
            "carModelActualTestBrakeDistance",
            "carModelMiitCompositeFuelConsumption",
            "carModelActualFuelConsumption",
            "carModelMiitEnduranceMileagePureElectric",
            "carModelQuickCharge",
            "carModelSlowCharge",
            "carModelQuickChargePercent",
            "carModelHorsePowerElectric",
            "carModelActualTestEnduranceMileage",
            "carModelActualTestQuickCharge",
            "carModelActualTestSlowCharge",
            "carModelWholeWarranty",
        ]
 
 
        for eachCarKey in carAllKeyList:
            if eachCarKey not in carModelDict:
                print("found miss key: %s" % eachCarKey)
                carModelDict[eachCarKey] = ""
 
 
        carModelSpecUrl = carModelDict["carModelSpecUrl"]
        self.send_message(self.project_name, carModelDict, url=carModelSpecUrl)
 
 
    def on_message(self, project, msg):
        print("on_message: msg=%s" % msg)
        return msg
其中用于测试的是:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
        插电式混合动力
            https://www.autohome.com.cn/spec/37077/
 
        汽油
            https://www.autohome.com.cn/spec/43593/
 
            https://car.autohome.com.cn/config/spec/16147.html
 
            https://www.autohome.com.cn/spec/46144/
 
        纯电动
            https://www.autohome.com.cn/spec/42875/
 
        油电混合
            https://car.autohome.com.cn/config/spec/35507.html
即可得到我们要的结果了
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
        """
        插电式混合动力
                {
                    "carBrandId": "33",
                    "carBrandName": "奥迪",
                    "carEnergyType": "插电式混合动力",
                    "carMerchantName": "奥迪(进口)",
                    "carMerchantUrl": "https://car.autohome.com.cn/price/brand-33-79.html#pvareaid=2042363",
                    "carModelActualFuelConsumption": "",
                    "carModelActualTestBrakeDistance": "",
                    "carModelActualTestEnduranceMileage": "",
                    "carModelActualTestQuickCharge": "",
                    "carModelActualTestSlowCharge": "",
                    "carModelActualTestSpeedupTime": "",
                    "carModelBodyStructure": "5门5座SUV",
                    "carModelDataSift2": "国V",
                    "carModelDataSift3": "2.0T",
                    "carModelDataSift4": "8挡手自一体",
                    "carModelDriveType": "前置四驱",
                    "carModelEngine": "2.0T 252马力 L4",
                    "carModelEnvStandard": "国V",
                    "carModelGearBox": "8挡手自一体",
                    "carModelGroupName": "2.0升 涡轮增压 252马力 国V",
                    "carModelHorsePowerElectric": "128",
                    "carModelMaxPower": "270",
                    "carModelMaxSpeed": "228",
                    "carModelMaxTorque": "700",
                    "carModelMiitCompositeFuelConsumption": "2.4",
                    "carModelMiitEnduranceMileagePureElectric": "56",
                    "carModelMsrp": "79.08万",
                    "carModelName": "2019款 55 e-tron",
                    "carModelOfficialSpeedupTime": "5.9",
                    "carModelQuickCharge": "2.5",
                    "carModelQuickChargePercent": "",
                    "carModelReleaseTime": "2018.11",
                    "carModelSize": "5071*1968*1716",
                    "carModelSlowCharge": "10.8",
                    "carModelSpecId": "37077",
                    "carModelSpecUrl": "https://www.autohome.com.cn/spec/37077/#pvareaid=3454492",
                    "carModelWholeWarranty": "三年或10万公里",
                    "carModelYear": "2019款",
                    "carSeriesId": "4460",
                    "carSeriesLevelId": "19",
                    "carSeriesLevelName": "中大型SUV",
                    "carSeriesMaxPrice": "79.08万",
                    "carSeriesMinPrice": "79.08万",
                    "carSeriesMsrp": "79.08-79.08万",
                    "carSeriesMsrpUrl": "https://www.autohome.com.cn/4460/price.html#pvareaid=101446",
                    "carSeriesName": "奥迪Q7新能源",
                    "carSeriesUrl": "https://www.autohome.com.cn/4460/#levelsource=000000000_0&pvareaid=101594"
                }
 
 
        汽油
                {
                    "carBrandId": "33",
                    "carBrandName": "奥迪",
                    "carEnergyType": "汽油",
                    "carMerchantName": "一汽-大众奥迪",
                    "carMerchantUrl": "https://car.autohome.com.cn/price/brand-33-9.html#pvareaid=2042363",
                    "carModelActualFuelConsumption": "",
                    "carModelActualTestBrakeDistance": "",
                    "carModelActualTestSpeedupTime": "",
                    "carModelBodyStructure": "5门5座两厢车",
                    "carModelDataSift2": "国VI",
                    "carModelDataSift3": "1.4T",
                    "carModelDataSift4": "7挡双离合",
                    "carModelDriveType": "前置前驱",
                    "carModelEngine": "1.4T 150马力 L4",
                    "carModelEnvStandard": "国VI",
                    "carModelGearBox": "7挡双离合",
                    "carModelGroupName": "1.4升 涡轮增压 150马力 国VI",
                    "carModelMaxPower": "110",
                    "carModelMaxSpeed": "200",
                    "carModelMaxTorque": "250",
                    "carModelMiitCompositeFuelConsumption": "5.8",
                    "carModelMsrp": "19.32万",
                    "carModelName": "2020款 改款 Sportback 35 TFSI 进取型 国VI",
                    "carModelOfficialSpeedupTime": "8.4",
                    "carModelReleaseTime": "2020.04",
                    "carModelSize": "4312*1785*1426",
                    "carModelSpecId": "43593",
                    "carModelSpecUrl": "https://www.autohome.com.cn/spec/43593/#pvareaid=3454492",
                    "carModelWholeWarranty": "三年或10万公里",
                    "carModelYear": "2020款",
                    "carSeriesId": "3170",
                    "carSeriesLevelId": "3",
                    "carSeriesLevelName": "紧凑型车",
                    "carSeriesMaxPrice": "23.46万",
                    "carSeriesMinPrice": "19.32万",
                    "carSeriesMsrp": "19.32-23.46万",
                    "carSeriesMsrpUrl": "https://www.autohome.com.cn/3170/price.html#pvareaid=101446",
                    "carSeriesName": "奥迪A3",
                    "carSeriesUrl": "https://www.autohome.com.cn/3170/#levelsource=000000000_0&pvareaid=101594"
                }
 
 
                {
                    "carBrandId": "91",
                    "carBrandName": "红旗",
                    "carEnergyType": "汽油",
                    "carMerchantName": "一汽红旗",
                    "carMerchantUrl": "https://car.autohome.com.cn/price/brand-91-190.html#pvareaid=2042363",
                    "carModelActualFuelConsumption": "",
                    "carModelActualTestBrakeDistance": "",
                    "carModelActualTestSpeedupTime": "",
                    "carModelBodyStructure": "4门5座三厢车",
                    "carModelDriveType": "后驱",
                    "carModelEngine": "2.0T 204马力 L4",
                    "carModelEnvStandard": "国IV(国V)",
                    "carModelGearBox": "6挡手自一体",
                    "carModelGroupName": "2.0升 涡轮增压 204马力",
                    "carModelMaxPower": "150",
                    "carModelMaxSpeed": "",
                    "carModelMaxTorque": "260",
                    "carModelMiitCompositeFuelConsumption": "9.8",
                    "carModelMsrp": "37.98万",
                    "carModelName": "2013款 2.0T 尊贵型",
                    "carModelOfficialSpeedupTime": "",
                    "carModelReleaseTime": "2013.05",
                    "carModelSize": "5095*1875*1485",
                    "carModelSpecId": "16147",
                    "carModelSpecUrl": "https://www.autohome.com.cn/spec/16147/",
                    "carModelWholeWarranty": "四年或10万公里",
                    "carModelYear": "2013款",
                    "carSeriesId": "2771",
                    "carSeriesLevelId": "5",
                    "carSeriesLevelName": "中大型车",
                    "carSeriesMaxPrice": "31.78万",
                    "carSeriesMinPrice": "25.28万",
                    "carSeriesMsrp": "25.28-31.78万",
                    "carSeriesMsrpUrl": "https://www.autohome.com.cn/2771/price.html#pvareaid=101446",
                    "carSeriesName": "红旗H7",
                    "carSeriesUrl": "https://www.autohome.com.cn/2771/#levelsource=000000000_0&pvareaid=101594"
                }
             
            {
                "carBrandId": "36",
                "carBrandName": "奔驰",
                "carEnergyType": "汽油",
                "carMerchantName": "北京奔驰",
                "carMerchantUrl": "https://car.autohome.com.cn/price/brand-36-152.html#pvareaid=2042363",
                "carModelActualFuelConsumption": "",
                "carModelActualTestBrakeDistance": "39.01",
                "carModelActualTestEnduranceMileage": "",
                "carModelActualTestQuickCharge": "",
                "carModelActualTestSlowCharge": "",
                "carModelActualTestSpeedupTime": "9.01",
                "carModelBodyStructure": "5门5座SUV",
                "carModelDataSift2": "国VI",
                "carModelDataSift3": "1.3T",
                "carModelDataSift4": "7挡双离合",
                "carModelDriveType": "前置前驱",
                "carModelEngine": "1.3T 163马力 L4",
                "carModelEnvStandard": "国VI",
                "carModelGearBox": "7挡双离合",
                "carModelGroupName": "1.3升 涡轮增压 163马力 国VI",
                "carModelHorsePowerElectric": "",
                "carModelMaxPower": "120",
                "carModelMaxSpeed": "207",
                "carModelMaxTorque": "250",
                "carModelMiitCompositeFuelConsumption": "6.1",
                "carModelMiitEnduranceMileagePureElectric": "",
                "carModelMsrp": "30.38万",
                "carModelName": "2020款 GLA 200",
                "carModelOfficialSpeedupTime": "9",
                "carModelQuickCharge": "",
                "carModelQuickChargePercent": "",
                "carModelReleaseTime": "2020.07",
                "carModelSize": "4417*1834*1610",
                "carModelSlowCharge": "",
                "carModelSpecId": "46144",
                "carModelSpecUrl": "https://www.autohome.com.cn/spec/46144/#pvareaid=3454492",
                "carModelWholeWarranty": "三年不限公里",
                "carModelYear": "2020款",
                "carSeriesId": "3248",
                "carSeriesLevelId": "17",
                "carSeriesLevelName": "紧凑型SUV",
                "carSeriesMaxPrice": "30.38万",
                "carSeriesMinPrice": "30.38万",
                "carSeriesMsrp": "30.38-30.38万",
                "carSeriesMsrpUrl": "https://www.autohome.com.cn/3248/price.html#pvareaid=101446",
                "carSeriesName": "奔驰GLA",
                "carSeriesUrl": "https://www.autohome.com.cn/3248/#levelsource=000000000_0&pvareaid=101594"
            }
 
 
        纯电动
                {
                    "carBrandId": "33",
                    "carBrandName": "奥迪",
                    "carEnergyType": "纯电动",
                    "carMerchantName": "一汽-大众奥迪",
                    "carMerchantUrl": "https://car.autohome.com.cn/price/brand-33-9.html#pvareaid=2042363",
                    "carModelActualTestBrakeDistance": "",
                    "carModelActualTestEnduranceMileage": "",
                    "carModelActualTestQuickCharge": "",
                    "carModelActualTestSlowCharge": "",
                    "carModelActualTestSpeedupTime": "",
                    "carModelBodyStructure": "5门5座SUV",
                    "carModelDataSift2": "100KW",
                    "carModelDataSift3": "265公里",
                    "carModelDataSift4": "单速",
                    "carModelDriveType": "前置前驱",
                    "carModelGearBox": "电动车单速变速箱",
                    "carModelGroupName": "电动 136马力",
                    "carModelHorsePowerElectric": "136",
                    "carModelMaxPower": "100",
                    "carModelMaxSpeed": "150",
                    "carModelMaxTorque": "290",
                    "carModelMiitEnduranceMileagePureElectric": "265",
                    "carModelMsrp": "22.68万",
                    "carModelName": "2019款 Q2L e-tron 纯电智酷型",
                    "carModelOfficialSpeedupTime": "",
                    "carModelQuickCharge": "0.6",
                    "carModelQuickChargePercent": "80",
                    "carModelReleaseTime": "2019.11",
                    "carModelSize": "4237*1785*1548",
                    "carModelSlowCharge": "17",
                    "carModelSpecId": "42875",
                    "carModelSpecUrl": "https://www.autohome.com.cn/spec/42875/#pvareaid=3454492",
                    "carModelWholeWarranty": "三年或10万公里",
                    "carModelYear": "2019款",
                    "carSeriesId": "5240",
                    "carSeriesLevelId": "16",
                    "carSeriesLevelName": "小型SUV",
                    "carSeriesMaxPrice": "23.73万",
                    "carSeriesMinPrice": "22.68万",
                    "carSeriesMsrp": "22.68-23.73万",
                    "carSeriesMsrpUrl": "https://www.autohome.com.cn/5240/price.html#pvareaid=101446",
                    "carSeriesName": "奥迪Q2L e-tron",
                    "carSeriesUrl": "https://www.autohome.com.cn/5240/#levelsource=000000000_0&pvareaid=101594"
                }
         
        油电混合
                {
                    "carBrandId": "52",
                    "carBrandName": "雷克萨斯",
                    "carEnergyType": "油电混合",
                    "carMerchantName": "雷克萨斯",
                    "carMerchantUrl": "https://car.autohome.com.cn/price/brand-52-65.html#pvareaid=2042363",
                    "carModelActualFuelConsumption": "",
                    "carModelActualTestBrakeDistance": "",
                    "carModelActualTestEnduranceMileage": "",
                    "carModelActualTestQuickCharge": "",
                    "carModelActualTestSlowCharge": "",
                    "carModelActualTestSpeedupTime": "",
                    "carModelBodyStructure": "5门5座两厢车",
                    "carModelDataSift2": "",
                    "carModelDataSift3": "",
                    "carModelDataSift4": "",
                    "carModelDriveType": "前驱",
                    "carModelEngine": "1.8L 99马力 L4",
                    "carModelEnvStandard": "国IV(国V)",
                    "carModelGearBox": "E-CVT无级变速",
                    "carModelGroupName": "1.8升 99马力",
                    "carModelHorsePowerElectric": "82",
                    "carModelMaxPower": "100",
                    "carModelMaxSpeed": "",
                    "carModelMaxTorque": "",
                    "carModelMiitCompositeFuelConsumption": "4.6",
                    "carModelMiitEnduranceMileagePureElectric": "",
                    "carModelMsrp": "26.70万",
                    "carModelName": "2018款 CT200h 多彩生活特别限量版",
                    "carModelOfficialSpeedupTime": "",
                    "carModelQuickCharge": "",
                    "carModelQuickChargePercent": "",
                    "carModelReleaseTime": "2018.08",
                    "carModelSize": "4360*1765*1455",
                    "carModelSlowCharge": "",
                    "carModelSpecId": "35507",
                    "carModelSpecUrl": "https://www.autohome.com.cn/spec/35507/",
                    "carModelWholeWarranty": "六年或15万公里",
                    "carModelYear": "2018款",
                    "carSeriesId": "2063",
                    "carSeriesLevelId": "3",
                    "carSeriesLevelName": "紧凑型车",
                    "carSeriesMaxPrice": "28.20万",
                    "carSeriesMinPrice": "21.50万",
                    "carSeriesMsrp": "21.50-28.20万",
                    "carSeriesMsrpUrl": "https://www.autohome.com.cn/2063/price.html#pvareaid=101446",
                    "carSeriesName": "雷克萨斯CT",
                    "carSeriesUrl": "https://www.autohome.com.cn/2063/#levelsource=000000000_0&pvareaid=101594"
                }
        """
目前暂时没太大问题了。

转载请注明:在路上 » 【已解决】汽车之家车型车系数据:抓取车型的详细参数配置

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
80 queries in 0.533 seconds, using 22.50MB memory