python抓取抖音热门视频_用于抓取抖音热门视频和音乐的API

注:项目已不可用...

DouYin

API of DouYin App for humans.

Installation

pip3 install douyin

Usage

Here is the sample code:

import douyin

from douyin.structures import Topic, Music

# define file handler and specify folder

video_file_handler = douyin.handlers.VideoFileHandler(folder='./videos')

music_file_handler = douyin.handlers.MusicFileHandler(folder='./musics')

# define mongodb handler

mongo_handler = douyin.handlers.MongoHandler()

# define downloader

downloader = douyin.downloaders.VideoDownloader([mongo_handler, video_file_handler, music_file_handler])

for result in douyin.hot.trend():

for item in result.data:

# download videos of topic/music for 100 max per

downloader.download(item.videos(max=100))

then you can get:

Item >

Processing > ...

Processing > ...

...

Processing > ...

Processing > ...

0%| | 0/10 [00:00, ?it/s]

Processing 1-10 of files

Processing > ...

Saving > to mongodb...

Processing > ...

Saving > to mongodb...

Processing > ...

....

Downloading > ...

Saved > to mongodb successfully

Downloading > ...

Saved > to mongodb successfully

Downloading > ...

Downloaded file to ./videos/6580510322468064526.mp4

10%|████▌ | 1/10 [00:01<00:16, 1.84s/it]

Downloaded file to ./videos/6516746291806997763.mp4

20%|█████████▏ | 2/10 [00:01<00:10, 1.33s/it]

Downloaded file to ./videos/6600742831352974596.mp4

40%|██████████████████▍ | 4/10 [00:02<00:05, 1.03it/s]

Downloaded file to ./videos/6484393014599879950.mp4

50%|███████████████████████ | 5/10 [00:02<00:04, 1.15it/s]

Downloaded file to ./videos/6616517521098935565.mp4

60%|███████████████████████████▌ | 6/10 [00:03<00:03, 1.27it/s]

Downloaded file to ./videos/6479958542747962637.mp4

70%|████████████████████████████████▏ | 7/10 [00:03<00:01, 1.68it/s]

Downloaded file to ./videos/6472305134377372941.mp4

80%|████████████████████████████████████▊ | 8/10 [00:03<00:00, 2.05it/s]

Downloaded file to ./videos/6562690160868199693.mp4

90%|█████████████████████████████████████████▍ | 9/10 [00:04<00:00, 2.27it/s]

Downloaded file to ./videos/6500385230921141518.mp4

100%|█████████████████████████████████████████████| 10/10 [00:04<00:00, 2.33it/s]

Examples

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值