linux环境继续使用chrome浏览器
This commit is contained in:
parent
160bf6777e
commit
51a0ac51df
18
lib/core.go
18
lib/core.go
|
@ -297,15 +297,19 @@ func (c *Core) initNotWindows() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
_, b := os.LookupEnv("PLAYWRIGHT_BROWSERS_PATH")
|
||||||
|
if !b {
|
||||||
err = os.Setenv("PLAYWRIGHT_BROWSERS_PATH", dir+"/tools/browser/")
|
err = os.Setenv("PLAYWRIGHT_BROWSERS_PATH", dir+"/tools/browser/")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("设置环境变量PLAYWRIGHT_BROWSERS_PATH失败" + err.Error())
|
log.Errorln("设置环境变量PLAYWRIGHT_BROWSERS_PATH失败" + err.Error())
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pwt, err := playwright.Run(&playwright.RunOptions{
|
pwt, err := playwright.Run(&playwright.RunOptions{
|
||||||
DriverDirectory: dir + "/tools/driver/",
|
DriverDirectory: dir + "/tools/driver/",
|
||||||
SkipInstallBrowsers: false,
|
SkipInstallBrowsers: false,
|
||||||
Browsers: []string{"firefox"},
|
Browsers: []string{"msedge", "chromium"},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("[core]", "初始化playwright失败")
|
log.Errorln("[core]", "初始化playwright失败")
|
||||||
|
@ -314,20 +318,20 @@ func (c *Core) initNotWindows() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.pw = pwt
|
c.pw = pwt
|
||||||
browser, err := pwt.Firefox.Launch(playwright.BrowserTypeLaunchOptions{
|
browser, err := pwt.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
|
||||||
Args: []string{
|
Args: []string{
|
||||||
"--disable-extensions",
|
"--disable-extensions",
|
||||||
"--disable-gpu",
|
"--disable-gpu",
|
||||||
"--start-maximized",
|
"--start-maximized",
|
||||||
"--no-sandbox",
|
"--no-sandbox",
|
||||||
"--window-size=500,450",
|
"--window-size=500,450",
|
||||||
// "--mute-audio",
|
"--mute-audio",
|
||||||
"--window-position=0,0",
|
"--window-position=0,0",
|
||||||
"--ignore-certificate-errors",
|
"--ignore-certificate-errors",
|
||||||
// "--ignore-ssl-errors",
|
"--ignore-ssl-errors",
|
||||||
// "--disable-features=RendererCodeIntegrity",
|
"--disable-features=RendererCodeIntegrity",
|
||||||
// "--disable-blink-features",
|
"--disable-blink-features",
|
||||||
// "--disable-blink-features=AutomationControlled",
|
"--disable-blink-features=AutomationControlled",
|
||||||
},
|
},
|
||||||
Channel: nil,
|
Channel: nil,
|
||||||
ChromiumSandbox: nil,
|
ChromiumSandbox: nil,
|
||||||
|
|
Loading…
Reference in New Issue