Comments (8)
Please fix the format of your markdown:
7 MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
generated by check-issue
from rod.
用法的问题,create 里处理 auth
from rod.
用法的问题,create 里处理 auth
如果改成在create中处理时则会报 panic: {-32000 Invalid state for continueInterceptedRequest }
create := func() *rod.Browser {
go browser.MustHandleAuth(user, pwd)()
return browser.MustIncognito()
}
from rod.
如果在外围处理,需要处理每个 auth 事件,browser.MustHandleAuth 只处理碰到的第一个,你看看它的源代码就懂了
from rod.
如果在外围处理,需要处理每个 auth 事件,browser.MustHandleAuth 只处理碰到的第一个,你看看它的源代码就懂了
我在每个goroutine中做处理不可实现吗,或者如果在外围统一处理的话,我查到是使用EachEvent去控制全部活动,我改成这样,依旧报错 panic: {-32000 Invalid state for continueInterceptedRequest }
go browser.EachEvent(func(e *proto.FetchAuthRequired) {
fakeAuth := &proto.FetchAuthChallengeResponse{
Response: proto.FetchAuthChallengeResponseResponseProvideCredentials,
Username: user,
Password: pwd,
}
err := proto.FetchContinueWithAuth{
RequestID: e.RequestID,
AuthChallengeResponse: fakeAuth,
}.Call(browser)
if err!=nil{
panic(err)
}
}, func(e *proto.FetchRequestPaused) {
err := proto.FetchContinueRequest{
RequestID: e.RequestID,
}.Call(browser)
if err!=nil{
panic(err)
}
})()
browsePool := rod.NewBrowserPool(20)
create := func() *rod.Browser {
return browser.MustIncognito()
}
// browser.MustPage()
from rod.
那你可能需要自己 debug 一下,应该是用法的问题,这方面 chromium cdp 缺少文档说明,只能猜测用法,让我来和让你来是一样的。
你这里报错的意思是 FetchContinueRequest 用法错误
from rod.
我看了您另外的一个回答 #654 ,我感觉我和他的问题应该是差不多的,但是我这里使用了BrowserPool,所以我猜测是不是BrowserPool的问题,以下是我的完整代码,此时报错信息是 navigation failed: net::ERR_INVALID_AUTH_CREDENTIALS
// Package main
// @Time : 2023-12-06 09:47
// @Author : wAnFen
// @File : render.go
// @Go : 1.21.3
package main
import (
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/launcher"
"github.com/go-rod/rod/lib/proto"
"log"
"sync"
)
func RunRod(url string) {
var rodUrl string
l := launcher.New().
Headless(false).
Leakless(true).
NoSandbox(true).
Delete("enable-automation").
Set("ignore-certificate-errors").
Set("ignore-certificate-errors-spki-list").
Set("ignore-ssl-errors").
Set("disable-blink-features", "AutomationControlled").
Set("disable-setuid-sandbox").
Set("disable-gpu").
Set("disable-dev-shm-usage").
Set("unlimited-storage").
Set("disable-accelerated-2d-canvas").
Set("full-memory-crash-report")
l = l.Proxy("http://127.0.0.1:6501")
path, has := launcher.LookPath()
if has == true {
rodUrl = l.Bin(path).MustLaunch()
} else {
rodUrl = l.MustLaunch()
}
log.Println("StartURL : ", rodUrl)
browser := rod.New().ControlURL(rodUrl).MustConnect()
browser.MustIgnoreCertErrors(true)
user := "user"
pwd := "pwd"
go browser.EachEvent(func(e *proto.FetchAuthRequired) {
fakeAuth := &proto.FetchAuthChallengeResponse{
Response: proto.FetchAuthChallengeResponseResponseProvideCredentials,
Username: user,
Password: pwd,
}
err := proto.FetchContinueWithAuth{
RequestID: e.RequestID,
AuthChallengeResponse: fakeAuth,
}.Call(browser)
if err != nil {
panic(err)
}
}, func(e *proto.FetchRequestPaused) {
err := proto.FetchContinueRequest{
RequestID: e.RequestID,
}.Call(browser)
if err != nil {
panic(err)
}
})()
browsePool := rod.NewBrowserPool(20)
create := func() *rod.Browser {
return browser.MustIncognito()
}
var wg sync.WaitGroup
for i := 0; i <= 3; i++ {
wg.Add(1)
go func() {
defer wg.Done()
b := browsePool.Get(create)
page, err := b.Page(proto.TargetCreateTarget{URL: url})
if err != nil {
log.Println("browser.Page Err : ", err)
}
println(page.MustElement("html").MustText())
}()
}
wg.Wait()
}
func main() {
RunRod("http://api.ipify.org")
}
from rod.
Related Issues (20)
- How run multiple instances of chrome and have one manager go rod which handle this instances HOT 2
- ElementX stuck if you specify a non-existent element HOT 2
- Repeat login HOT 2
- 如何模拟鼠标滚动向下拉取加载数据? HOT 10
- Leakless feature problems... HOT 1
- 当浏览器关闭时,chrome_crashpad_handler和Chromium Helper两个进程没有被关闭。 HOT 3
- Is it possible to improve Screenshot's fullPage implementation? HOT 1
- Why doesn't it remember the window size now? HOT 11
- How to cancel the timeout for Elements (not just one)? HOT 1
- Intercept DevTools disconnection HOT 3
- How to ignore cert errors when HijackRequests is used? HOT 3
- Proxy auth dialog handler is not working in another tab HOT 4
- Is there a way to change or get download directory of browser? HOT 8
- page.Elements result have cache? HOT 1
- chromium can't login gmail account HOT 11
- NewUserMode最多启动2个浏览器,在尝试启动2个以上浏览器后卡住 HOT 11
- Alert Trojan Virus HOT 2
- After setting the default system device, the viewport display height and width are reversed. HOT 2
- hijack无法加载Other类型请求 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rod.