|
@@ -523,9 +523,12 @@
|
|
|
loginUrl(url){
|
|
|
(async () => {
|
|
|
try{
|
|
|
+ url = 'https://www.douyin.com';
|
|
|
if (!fs.existsSync(os.tmpdir() + separator + 'chrome-data-capture')) {
|
|
|
fs.mkdirSync(os.tmpdir() + separator + 'chrome-data-capture');
|
|
|
}
|
|
|
+ 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";
|
|
|
+
|
|
|
const tbBrowser = await puppeteer.launch({
|
|
|
headless: false,
|
|
|
executablePath: puppeteer.executablePath().replace('win32-1', 'win64-1'),
|
|
@@ -533,6 +536,8 @@
|
|
|
userDataDir: os.tmpdir() + separator + 'chrome-data-capture',
|
|
|
});
|
|
|
const page = await tbBrowser.newPage();
|
|
|
+ // await page.setRequestInterception(true);
|
|
|
+ await page.setUserAgent(UA);
|
|
|
await page.setViewport({ width: 1280, height: 800 });
|
|
|
|
|
|
await page.evaluateOnNewDocument(() => {
|
|
@@ -540,6 +545,29 @@
|
|
|
delete newProto.webdriver;
|
|
|
navigator.__proto__ = newProto;
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
+ let videoUrls = [];
|
|
|
+ page.on('response', async(response) => {
|
|
|
+ if (response.headers()['content-type'] && response.headers()['content-type'].startsWith('video/')) {
|
|
|
+
|
|
|
+ console.log('---', response.url())
|
|
|
+ let i = 0;
|
|
|
+ if(videoUrls.indexOf(response.url()) < 0){
|
|
|
+ i++;
|
|
|
+ videoUrls.push(response.url());
|
|
|
+
|
|
|
+ this.downloadImage(response.url(), "D:/桌面/抖音"+i+'.mp4');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
await page.goto(url, {waitUntil : 'networkidle2'});
|
|
|
}catch(e){
|
|
|
this.showError(e);
|
|
@@ -766,6 +794,7 @@
|
|
|
|
|
|
// 下载网址链接的图片
|
|
|
async downloadImage(imageUrl, outputPath, urlInfo) {
|
|
|
+ console.log(imageUrl, outputPath);
|
|
|
let _this = this;
|
|
|
let received_bytes = 0;
|
|
|
let total_bytes = 0;
|