Answer the question
In order to leave comments, you need to log in
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
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(); //закрываем браузер
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question