how to add urls to Flash white list in puppeteer

耗尽温柔 提交于 2019-12-11 09:20:10

问题


I develop small crawler with puppeteer in Node.js. the target site has Flash contents, so I want to enable Flash in puppeteer.

by default, puppeteer is unable to use Flash and white list of permitted sites is empty. I know how to enable Flash in puppeteer, but I don't know how to set white list.

How to do that? Is there flag like this?

const browser = await puppeteer.launch({
        headless: false,
        args: [
            '--ppapi-flash-path = {FLASH_PATH}',
            '--white-url = {TARGET_URL}'
        ]
    });

Or, is it only way to simply manipulate DOM in setting page in browser (ex.chrome://settings/content/flash)?


回答1:


I've solved the problem myself. I can't find the flag of Flash white list and manipulate DOM of chrome's setting page is too tiring for me, but I got useful some params.

1. 'userDataDir: {PROFILE_FILE}'

First, manually launch chrome or chromium, and add url to the list. Then, set PROFILE_FILE as its user data path.

2. executablePath: '{PATH_TO_CHROME}'

Basically, run on chrome but not chromium, we can use Flash and HLS and etc. by default. Set manually white list, and it works.




回答2:


After much tinkering I found a Preferences file configuration that whitelists all flash content by default.

I've made a small puppeteer wrapper to make using this very easy: puppeteer.setExtra({allowFlash: true})

{
  "profile": {
    "content_settings": {
      "exceptions": {
        "flash_data": {
          "*,*": {
            "setting": {
              "flashPreviouslyChanged": true
            }
          }
        },
        "permission_autoblocking_data": {
          "*,*": {
            "setting": {
              "Flash": {
                "dismiss_count": 1
              }
            }
          }
        },
        "plugins": {
          "*,*": {
            "per_resource": {
              "adobe-flash-player": 1
            }
          }
        }
      },
      "pref_version": 1
    }
  }
}


来源:https://stackoverflow.com/questions/50008895/how-to-add-urls-to-flash-white-list-in-puppeteer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!