Skip to content

Instantly share code, notes, and snippets.

@dkmeteor
Created March 19, 2019 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkmeteor/511819e59185542c33c82530f04f7a41 to your computer and use it in GitHub Desktop.
Save dkmeteor/511819e59185542c33c82530f04f7a41 to your computer and use it in GitHub Desktop.
download douyin videos 批量下载抖音视频
# coding=UTF-8
# import requests
import urllib
import urllib.request
# import urllib2
# 文件路径
path = '/Users/dk/Desktop/抖音/'
num = 0
downloadPool = []
def response(flow):
global num
# 抖音视频CDN地址列表
target_urls = ['http://v1-dy.ixigua.com/','http://v1-dy-x.ixigua.com/','http://v1-dy-y.ixigua.com/','http://v1-dy-z.ixigua.com/',
'http://v3-dy.ixigua.com/','http://v3-dy-x.ixigua.com/', 'http://v3-dy-y.ixigua.com/', 'http://v3-dy-z.ixigua.com',
'http://v6-dy.ixigua.com/','http://v6-dy-x.ixigua.com/','http://v6-dy-y.ixigua.com/','http://v6-dy-z.ixigua.com/',
'http://v9-dy-z.ixigua.com/','http://v9-dy.ixigua.com/','http://v9-dy-x.ixigua.com/','http://v9-dy-y.ixigua.com/'
]
for url in target_urls:
if flow.request.url.startswith(url):
if flow.request.url in downloadPool :
continue
else :
downloadPool.append(flow.request.url)
filename = path + str(num) + '.mp4'
urllib.request.urlretrieve(flow.request.url, filename)
num += 1
@dkmeteor
Copy link
Author

配合 mitmproxy 使用.
https://www.mitmproxy.org/

命令行执行 mitmdump -s script.py
自动抓取抖音视频到本地

可配合appium等工具 自动化操作步骤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment