- A+
所属分类:未分类
想法
浏览器打开分享某个小姐姐的url,如:http://v.douyin.com/RKtWhT/,如下图
其中,有个url如下:
https://www.iesdouyin.com/aweme/v1/aweme/post/?user_id=97166800196&count=21&max_cursor=0&aid=1128&_signature=BMEQLRAVX0Su7lCtnbSpbATBED&dytk=1c778a12242564117f3ba93e914afbd7
发现直接访问该链接,该小姐姐的所有视频,图片的json串都出来了,如果每次打开浏览器的话,也太麻烦了,所以就写个程序模拟一下,如下:
puppeteer安装
puppeteer安装,之前我已经详细说过了,win10+node10.13.0+npm6.4.1+puppeteer6.4
写node脚本
安装完成后,测试没问题后,创建文件douyin.js,内容如下:
const puppeteer = require('puppeteer'); puppeteer.launch().then(async browser => { const page = await browser.newPage(); //设置启用拦截 await page.setRequestInterception(true); //设置浏览器 const UA = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36"; await page.setUserAgent(UA); page.on('request', request => { if (request.url().endsWith('.png') || request.url().endsWith('.jpg') || request.url().endsWith('.css')){ request.abort(); }else{ request.continue(); // if (request.url().length>150) if(request.url().indexOf('https://www.iesdouyin.com/aweme/v1/aweme/post') != -1) { page.on('response', response => { response.text().then(function (textBody) { console.log(textBody); }) }); } } }); await page.goto('http://v.douyin.com/RKtWhT/'); await browser.close(); });
执行脚本
命令如下:
E:\>node douyin.js
查看结果
结果返回的是json串,太多,我这里取出一段,里面有带水印的,也有不带水印的,自己解析下去吧。
"video": {"video": { "play_addr": { "url_list": ["https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200f0f0000bfvjqk9pjc2lk4v3ikjg&line=0", "https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200f0f0000bfvjqk9pjc2lk4v3ikjg&line=1"], "uri": "v0200f0f0000bfvjqk9pjc2lk4v3ikjg" }, "height": 960, "cover": { "url_list": ["https://p99.pstatp.com/large/126cf00090eaf44a0cb98.jpg", "https://pb3.pstatp.com/large/126cf00090eaf44a0cb98.jpg", "https://pb3.pstatp.com/large/126cf00090eaf44a0cb98.jpg"], "uri": "large/126cf00090eaf44a0cb98" }, "dynamic_cover": { "url_list": ["http://p3.pstatp.com/obj/1282f0001a0da271b2deb", "http://pb9.pstatp.com/obj/1282f0001a0da271b2deb", "http://pb3.pstatp.com/obj/1282f0001a0da271b2deb"], "uri": "1282f0001a0da271b2deb" }
说明一下
http://v.douyin.com/RKtWhT/这个地址是分享时的链接
- 安卓客户端下载
- 微信扫一扫
- 微信公众号
- 微信公众号扫一扫