-
-
[原创]Python 懂车帝综合口碑数据
-
发表于: 2022-4-4 06:58 16325
-
<table><tr><td bgcolor=orange>本文所有教程及源码、软件仅为技术研究。不涉及计算机信息系统功能的删除、修改、增加、干扰,更不会影响计算机信息系统的正常运行。不得将代码用于非法用途,如侵立删!</td></tr></table>
懂车帝全系车型综合口碑 优点 缺点 统计数据
先来web端试下能否找到需要的数据接口,随便找个车型打开口碑页面F12查看Network
根据页面关键词搜索没有找到明显的数据接口,虽然说现在也可以使用request或者selenium直接在页面解析数据,但是毕竟这不是首选方案,还是从APP分析一下在决定用什么方案。
PS:手机环境、抓包环境的配置在这不在赘述,有兴趣的可参考之前的文章 APP抓包环境配置
下载懂车帝APP,并安装至手机
手机开启Postern,pc打开charles
至此抓包工作准备完成,打开懂车帝APP,随便找个车型进入懂车分页面
还是老套路先根据页面关键词搜索一波
明显看出来后两条数据不是需要的,前四条是同一个接口返回的,应该就是需要的数据,双击点进去看一下详细数据
初步查看和页面数据是一致的,看数据结构和具体的数值和页面中的数据很像,Charles界面太小,将数据拷贝至网页中解析,方便分析,分享一个常用的json数据在线解析网站
经过仔细对比页面中的数据,发现此接口就是我们需要的
综合口碑接口:
对!你没看错,就是这么长,验证一下数据接口,在网页中直接请求一下这个url
这儿推荐安装一个网页json可视化的插件,这儿偷懒没装,在线解析了一下json数据,和Charles抓到的数据是一样,经过分析得知: series_id是车系id,修改此参数即可
获取车系id就很简单了,先拿到品牌id然后根据品牌id请求车系信息,注意这是一个post接口
https://download.csdn.net/download/qq_38154948/85073968
<table><tr><td bgcolor=orange>本文仅供学习交流使用,如侵立删!</td></tr></table>
https:
/
/
*
*
*
*
*
*
*
/
get_detail
/
?series_id
=
4182
&car_id
=
0
&only_owner
=
0
&year_id
=
all
&iid
=
2467735824764398
&device_id
=
40011211486215
&ac
=
wifi&channel
=
dcd
-
yd
-
11zh
-
and
-
74
&aid
=
36
&app_name
=
automobile&version_code
=
693
&version_name
=
6.9
.
3
&device_platform
=
android&os
=
android&ab_client
=
a1
%
2Cc2
%
2Ce1
%
2Cf2
%
2Cg2
%
2Cf7
&ab_group
=
3167590
%
2C3577236
%
2C3333988
&ssmix
=
a&device_type
=
Nexus
+
5X
&device_brand
=
google&language
=
zh&os_api
=
27
&os_version
=
8.1
.
0
&manifest_version_code
=
693
&resolution
=
1080
*
1794
&dpi
=
420
&update_version_code
=
6931
&_rticket
=
1648907286543
&cdid
=
f3163204
-
7faf
-
45d7
-
89c4
-
e82215c3216c&city_name
=
%
E8
%
81
%
8A
%
E5
%
9F
%
8E
&gps_city_name
=
%
E8
%
81
%
8A
%
E5
%
9F
%
8E
&selected_city_name&rom_version
=
27
&longi_lati_type
=
1
&longi_lati_time
=
1648907102913
&content_sort_mode
=
0
&total_memory
=
1.77
&cpu_name
=
Qualcomm
+
Technologies
%
2C
+
Inc
+
MSM8992&overall_score
=
4.873
&cpu_score
=
4.8872
&host_abi
=
https:
/
/
*
*
*
*
*
*
*
/
get_detail
/
?series_id
=
4182
&car_id
=
0
&only_owner
=
0
&year_id
=
all
&iid
=
2467735824764398
&device_id
=
40011211486215
&ac
=
wifi&channel
=
dcd
-
yd
-
11zh
-
and
-
74
&aid
=
36
&app_name
=
automobile&version_code
=
693
&version_name
=
6.9
.
3
&device_platform
=
android&os
=
android&ab_client
=
a1
%
2Cc2
%
2Ce1
%
2Cf2
%
2Cg2
%
2Cf7
&ab_group
=
3167590
%
2C3577236
%
2C3333988
&ssmix
=
a&device_type
=
Nexus
+
5X
&device_brand
=
google&language
=
zh&os_api
=
27
&os_version
=
8.1
.
0
&manifest_version_code
=
693
&resolution
=
1080
*
1794
&dpi
=
420
&update_version_code
=
6931
&_rticket
=
1648907286543
&cdid
=
f3163204
-
7faf
-
45d7
-
89c4
-
e82215c3216c&city_name
=
%
E8
%
81
%
8A
%
E5
%
9F
%
8E
&gps_city_name
=
%
E8
%
81
%
8A
%
E5
%
9F
%
8E
&selected_city_name&rom_version
=
27
&longi_lati_type
=
1
&longi_lati_time
=
1648907102913
&content_sort_mode
=
0
&total_memory
=
1.77
&cpu_name
=
Qualcomm
+
Technologies
%
2C
+
Inc
+
MSM8992&overall_score
=
4.873
&cpu_score
=
4.8872
&host_abi
=
def
get_series(
self
, brand_id):
"""
获取品牌所有车系
brand_id:品牌id
"""
headers
=
{
'User-Agent'
:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36'
}
param
=
{
'offset'
:
0
,
'limit'
:
1000
,
'is_refresh'
:
1
,
'city_name'
:
'北京'
,
'brand'
: brand_id
}
response
=
requests.post(url
=
url, data
=
param, headers
=
headers)
rep_json
=
json.loads(response.text)
# print(response.text)
if
rep_json[
'status'
]
=
=
'success'
:
return
rep_json[
'data'
][
'series'
]
else
:
raise
Exception(
"get car series has exception!"
)
def
get_series(
self
, brand_id):
"""
获取品牌所有车系
brand_id:品牌id
"""
headers
=
{
'User-Agent'
:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36'
}
param
=
{
'offset'
:
0
,
'limit'
:
1000
,
'is_refresh'
:
1
,
'city_name'
:
'北京'
,
'brand'
: brand_id
}
response
=
requests.post(url
=
url, data
=
param, headers
=
headers)