允许在Puppeteer中的所有站点上运行Flash [英] Allowing to run Flash on all sites in Puppeteer
问题描述
免责声明:我知道Flash将在2020年底被抛弃,但我不能放弃这个案例,需要在木偶中安装Flash,尽管我也不喜欢这样。
我需要爬行某些闪存网站,并采取他们的屏幕截图,为以后的编程比较。我可以提供需要检查的域的有限列表(尽管列表可能会随时间变化,因此能够以某种方式在运行时加载它们将是很棒的)。
我在网上寻找解决方案已经有一段时间了,我在SA问题上得到的最接近的问题是:how to add urls to Flash white list in puppeteer
在使用puppeteer-extra-plugin-flash
、为PepperFlash
提供路径和版本并运行Chrome可执行文件而不是Chromium之后,我设法让Flash站点被正确识别,但我仍然需要单击灰色的拼图才能允许Flash在任何网站上运行。
我就是找不到在2019年7月有效的解决方案。
我已尝试使用各种参数:
--ppapi-in-process ||
--disable-extensions-except=${pluginPath}/.. ||
--allow-outdated-plugins ||
--no-user-gesture-required
和更多,可能是无关的。对其他人来说似乎最成功的方法似乎是使用PluginsAllowedForUrls
并提供带有通配符的URL列表,然后通过--user-data-dir
加载预定义的配置文件-但在这方面我也没有运气(我想我在准备正确的配置文件时遇到了问题)。
我正在构建的这个工具不会公开,仅供受过教育的团队在内部使用-因此我没有太多的安全约束需要关心。我只需要木偶戏里的闪电侠。我也不需要关心它的Docker化。
我当前的设置,简化:
// within async function
const browser = await puppeteer.launch({
headless: false,
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
args: [
'--window-size=800,600',
'--enable-webgl',
'--enable-accelerated-2d-canvas',
`--user-data-dir=${path.join(process.cwd(), 'chrome-user-data')}`
// '--always-authorize-plugins', -> does not seem to be doing anything in our case
// '--enable-webgl-draft-extensions', -> does not seem to be doing anything in our case
// '--enable-accelerated-vpx-decode', -> does not seem to be doing anything in our case
// '--no-user-gesture-required', -> does not seem to be doing anything in our case
// '--ppapi-in-process', -> does not seem to be doing anything in our case
// '--ppapi-startup-dialog', -> does not seem to be doing anything in our case
// `--disable-extensions-except=${pluginPath}/..`, -> does not solve issue with blocked
// '--allow-outdated-plugins', -> does not seem to be doing anything in our case
],
});
const context = await browser.defaultBrowserContext();
const page = await context.newPage();
const url = new URL('http://ultrasounds.com');
const response = await fetch(url.href);
await page.setViewport({ width: 800, height: 600});
await page.goto(url.href, { waitUntil: 'networkidle2' });
await page.waitFor(10000);
const screenshot = await page.screenshot({
encoding: 'binary',
});
Chrome version: 75.0.3770.100
,
puppeteer-extra: 2.1.3
puppeteer-extra-plugin-flash: 2.13
任何形式的指导都很感谢,如果有一些工作实例会很好,提前谢谢!
推荐答案
我设法做到了。我找到了较旧的Chrome版本(65),并将其与puppeteer-extra
一起运行。
我使用并正在运行的库的版本:
PepperFlashPlugin版本:32.0.0.223
Google Chrome:65.0.3325.181
Puppeteer-core:1.7.0
(如果需要不同于65,请查看对应版本的标签)
puppeteer-extra
:2.1.3
puppeteer
:1.0.0
puppeteer-extra-plugin-flash
:2.1.3
启动浏览器如下所示:
const browser = await PuppeteerExtra.launch({
headless: false,
executablePath: process.env.CHROME_EXECUTABLE,
args: [
'--window-size=800,600',
'--enable-webgl',
'--enable-accelerated-2d-canvas',
],
});
const page = await this.fBrowser.newPage();
await page.setViewport({ width: 800, height: 600});
await page.goto('http://ultrasounds.com', { waitUntil: 'networkidle2' });
而且还能用!🎉
这篇关于允许在Puppeteer中的所有站点上运行Flash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!