0%

豆瓣接口分析

豆瓣接口

1.豆瓣接口_sig签名算法

豆瓣签名使用HMAC-SHA1的签名算法
HMAC-SHA1(key,data)包含两个参数
key为密钥,data为加密信息
豆瓣接口的key值可以通过抓豆瓣登录的数据包,获得client_secret的值

1
https://$host$url?os_rom=android&apikey=0dad那个你懂得&channel=Douban&_sig=$sig&_ts=$ts"

分为登录状态和非登录状态

非登录状态

非登录状态下的data="GET&" + URLEncoder.encode(url) + "&" + ts

ts为当前时间戳,url按照上面提示的格式截取

1
GET frodo.douban.com/api/v2/subject_collection/movie_hot_gaia/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban

其中data = GET&%2Fapi%2Fv2%2Fskynet%2Fnew_playlists&1585718766

登录状态

登录状态下http的头部会多出一个参数,如下:

1
Authorization: Bearer 9931b7883f68a4dbcb952698be39ee91

登录状态下的data="GET&" + URLEncoder.encode(url) + "&9931b7883f68a4dbcb952698be39ee91" +"&" + ts

此时的data = GET&%2Fapi%2Fv2%2Fskynet%2Fnew_playlists&9931b7883f68a4dbcb952698be39ee91&1585718766

算法js代码实现在TZVideo项目中点这里

==注意哦==header一定要加User-agent

最后得到的加密签名为encodeURIComponent(HMAC-SHA1(key,sigString))

2.豆瓣热播电影

1
2
3
4
5
6
7
GET frodo.douban.com/api/v2/subject_collection/movie_hot_gaia/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban

HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip

2.豆瓣热门电视剧

热门 综合

1
2
3
4
5
6
GET frodo.douban.com/api/v2/subject_collection/tv_hot/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip

热门 国产剧

1
2
3
4
5
6
GET frodo.douban.com/api/v2/subject_collection/tv_domestic/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip

热门 美剧

1
2
3
4
5
6
GET frodo.douban.com/api/v2/subject_collection/tv_american/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip

热门 日剧

1
2
3
4
5
6
GET frodo.douban.com/api/v2/subject_collection/tv_japanese/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip

热门 韩剧

1
2
3
4
5
6
GET frodo.douban.com/api/v2/subject_collection/tv_korean/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip

热门 动漫

1
2
3
4
5
6
GET frodo.douban.com/api/v2/subject_collection/tv_animation/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip

33.

1
2
3
4
5
GET /api/v2/subject_collection/show_foreign/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&rom=android&apikey=0dad551ec0f84ed02907ff5c42e8ec70&s=rexxar_new&channel=Douban&device_id=a4684a67c5db66436da276d582163766f927d703&os_rom=android&apple=49db722f1873da2794d1345d984636c2&icecream=f19780352d2a7036d216fad19e8ebee3&mooncake=65316193bbe4cb682856b448f447a4a7&sugar=46007&loc_id=118215&_sig=peOCRQGOKWrxlsy9%2F%2BYSq6RPmFk%3D&_ts=1585240659 HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip

4.片单接口

getc参数只需要保留start,count,category,apikey,channel

1. 豆瓣片单 全部

mark

1
2
3
4
5
6
GET frodo.douban.com/api/v2/skynet/new_playlists?start=0&count=20&category=all&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip

2. 豆瓣片单 精选

mark

1
2
3
4
5
6
GET frodo.douban.com/api/v2/skynet/new_playlists?start=0&count=20&category=selected&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip

3 .豆瓣片单 经典

mark

1
2
3
4
5
6
GET frodo.douban.com/api/v2/skynet/new_playlists?start=0&count=20&category=classical&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip

4 .豆瓣片单 豆瓣片单

mark

1
2
3
4
5
6
GET frodo.douban.com/api/v2/skynet/new_playlists?start=0&count=20&category=official&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip

5 .豆瓣片单 高分

mark

1
2
3
4
5
6
GET frodo.douban.com/api/v2/skynet/new_playlists?start=0&count=20&category=official&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip

其他

根据category的参返回不同的片单,category的 参数为下面key值

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
categories": [
{
"items": [
{
"key": "all",
"title": "全部"
},
{
"key": "official",
"title": "豆瓣片单"
},
{
"key": "selected",
"title": "精选"
},
{
"key": "classical",
"title": "经典"
},
{
"key": "prize",
"title": "获奖"
},
{
"key": "high_score",
"title": "高分"
},
{
"key": "movie_list",
"title": "榜单"
},
{
"key": "dark_horse",
"title": "冷门佳片"
}
],
"name": "全部"
},
{
"items": [
{
"key": "chinese",
"title": "华语"
},
{
"key": "western",
"title": "欧美"
},
{
"key": "japanese",
"title": "日本"
},
{
"key": "korea",
"title": "韩国"
}
],
"name": "地域"
},
{
"items": [
{
"key": "comedy",
"title": "喜剧"
},
{
"key": "love",
"title": "爱情"
},
{
"key": "science_fiction",
"title": "科幻"
},
{
"key": "cartoon",
"title": "动画"
},
]
}