草庐IT

javascript - 允许在 Puppeteer 的所有站点上运行 Flash

coder 2025-03-21 原文

免责声明:我知道 Flash 将在 2020 年底被放弃,但我不能放弃这个案例,需要在 Puppeteer 中使用 Flash,尽管我也不喜欢它。

我需要抓取某些 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 加载预定义的配置文件 -但我在这件事上也不走运(我想我在准备适当的个人资料方面遇到了问题)。

我正在构建的这个工具不会公开,仅供受过教育的团队在内部使用 - 因此我没有太多的安全限制需要关心。我只需要 puppeteer 操纵者中的 Flash。我也不需要关心它的 Dockerizing。

我当前的设置,已简化:


// 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 版本:75.0.3770.100puppeteer-extra:2.1.3 puppeteer-extra-plugin-flash:2.13

感谢任何形式的指导,如果有一些工作示例会很高兴,在此先感谢!

最佳答案

我成功了。我找到了较旧的 Chrome 版本 (65),并使用 puppeteer-extra 运行它。

我使用和正在运行的库版本:

PepperFlashPlugin 版本:32.0.0.223

谷歌浏览器: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' });

而且有效! ?

关于javascript - 允许在 Puppeteer 的所有站点上运行 Flash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57005040/

有关javascript - 允许在 Puppeteer 的所有站点上运行 Flash的更多相关文章

  1. ruby - 如何从 ruby​​ 中的字符串运行任意对象方法? - 2

    总的来说,我对ruby​​还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用

  2. ruby - 如何以所有可能的方式将字符串拆分为长度最多为 3 的连续子字符串? - 2

    我试图获取一个长度在1到10之间的字符串,并输出将字符串分解为大小为1、2或3的连续子字符串的所有可能方式。例如:输入:123456将整数分割成单个字符,然后继续查找组合。该代码将返回以下所有数组。[1,2,3,4,5,6][12,3,4,5,6][1,23,4,5,6][1,2,34,5,6][1,2,3,45,6][1,2,3,4,56][12,34,5,6][12,3,45,6][12,3,4,56][1,23,45,6][1,2,34,56][1,23,4,56][12,34,56][123,4,5,6][1,234,5,6][1,2,345,6][1,2,3,456][123

  3. ruby - 如何每月在 Heroku 运行一次 Scheduler 插件? - 2

    在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/

  4. ruby-on-rails - 如何在 ruby​​ 中使用两个参数异步运行 exe? - 2

    exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby​​中使用两个参数异步运行exe吗?我已经尝试过ruby​​命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何ruby​​gems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除

  5. ruby - 无法运行 Rails 2.x 应用程序 - 2

    我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby​​:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r

  6. ruby - Sinatra:运行 rspec 测试时记录噪音 - 2

    Sinatra新手;我正在运行一些rspec测试,但在日志中收到了一堆不需要的噪音。如何消除日志中过多的噪音?我仔细检查了环境是否设置为:test,这意味着记录器级别应设置为WARN而不是DEBUG。spec_helper:require"./app"require"sinatra"require"rspec"require"rack/test"require"database_cleaner"require"factory_girl"set:environment,:testFactoryGirl.definition_file_paths=%w{./factories./test/

  7. ruby-on-rails - 跳过状态机方法的所有验证 - 2

    当我的预订模型通过rake任务在状态机上转换时,我试图找出如何跳过对ActiveRecord对象的特定实例的验证。我想在reservation.close时跳过所有验证!叫做。希望调用reservation.close!(:validate=>false)之类的东西。仅供引用,我们正在使用https://github.com/pluginaweek/state_machine用于状态机。这是我的预订模型的示例。classReservation["requested","negotiating","approved"])}state_machine:initial=>'requested

  8. ruby - Nokogiri 剥离所有属性 - 2

    我有这个html标记:我想得到这个:我如何使用Nokogiri做到这一点? 最佳答案 require'nokogiri'doc=Nokogiri::HTML('')您可以通过xpath删除所有属性:doc.xpath('//@*').remove或者,如果您需要做一些更复杂的事情,有时使用以下方法遍历所有元素会更容易:doc.traversedo|node|node.keys.eachdo|attribute|node.deleteattributeendend 关于ruby-Nokog

  9. ruby-on-rails - RSpec:避免使用允许接收的任何实例 - 2

    我正在处理旧代码的一部分。beforedoallow_any_instance_of(SportRateManager).toreceive(:create).and_return(true)endRubocop错误如下:Avoidstubbingusing'allow_any_instance_of'我读到了RuboCop::RSpec:AnyInstance我试着像下面那样改变它。由此beforedoallow_any_instance_of(SportRateManager).toreceive(:create).and_return(true)end对此:let(:sport_

  10. ruby - 获取模块中定义的所有常量的值 - 2

    我想获取模块中定义的所有常量的值:moduleLettersA='apple'.freezeB='boy'.freezeendconstants给了我常量的名字:Letters.constants(false)#=>[:A,:B]如何获取它们的值的数组,即["apple","boy"]? 最佳答案 为了做到这一点,请使用mapLetters.constants(false).map&Letters.method(:const_get)这将返回["a","b"]第二种方式:Letters.constants(false).map{|c

随机推荐