D
D
Daniel Chistyakov2021-05-08 20:40:44
Node.js
Daniel Chistyakov, 2021-05-08 20:40:44

How to remove a link to a video or photo using Node.JS?

Good day, how can I extract a link to a file using Node.JS (preferably Puppetter or Cheerio, but not necessary)? The file is visible in the "Network" tab of the console (it just loads, but does not appear in the DOM itself).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniel Chistyakov, 2021-05-11
@danielchistyakov

Who might find it useful:
Puppeteer has a waitForResponse

const express = require('express');
const router = express.Router();
const chromium = require('chrome-aws-lambda');
app.get('/', async function (req, res) => {

//Запуск браузера сделан под деплоер!!!

const browser = await chromium.puppeteer.launch({
        args: chromium.args,
        defaultViewport: chromium.defaultViewport,
        executablePath: await chromium.executablePath,
        headless: chromium.headless,
        ignoreHTTPSErrors: true,
    });

const page = await browser.newPage(); //новая вкладка
    await page.goto(`наш сайт`);
    await page.waitForSelector('Селектор последнего DOM-элемента');
    await page.mouse.click(400, 300); //в моём случае нужен был клик
    const res = await page.waitForResponse(response => response.url().includes('хотя бы кусочек имени желаемого запроса'));
    const url = await res.url(); //вынимаем ссылку
    res.send({ url: result }); //здесь я отправлял результат в API, можно сделать любой вывод
    await browser.close(); //закрываем браузер
})

D
Dmitry Belyaev, 2021-05-08
@bingo347

https://www.npmjs.com/package/puppeteer-request-spy

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question