Comments (11)
You can set the request auth header by this API: https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-setExtraHTTPHeaders
The header looks like this Proxy-Authorization: Basic dXNlcjpwYXNzd29yZA==
.
dXNlcjpwYXNzd29yZA==
is base64 of user:password
from rod.
I try it :
page.Call("Network.setExtraHTTPHeaders", cdp.Object{ "Proxy-Authorization": "Basic dXNlcjpwYXNzd29yZA==", })
the error is panic: {"code":-32602,"message":"Invalid parameters","data":"headers: object expected"}
Is the parameter format incorrect?
from rod.
The error message is already telling you you missed the headers
π
It's like Call({ headers: { a: b } })
, not Call({ a: b })
from rod.
BTW, I added page.SetExtraHeaders
in version v0.29.1
, you can use that directly:
This is the example code:
https://github.com/ysmood/rod/blob/f397ccbb88efc50352fc97574d71b0d3655a8755/page_test.go#L57
from rod.
The new version of Rod is type-safe when you send low-level requests to chrome. This kind of issue won't happen again, check the example:
https://github.com/ysmood/rod/blob/3ff68f7d645f24c0978878939164f01bd39d88a2/examples_test.go#L175
from rod.
I use page.SetExtraHeaders("Proxy-Authorization", "Basic "+temp)
but it not work , is it rigth?
key/value use comma separated?
Can you change it to
var dict map[string]string = map[string]string{"Proxy-Authorization":"Basic "+temp} page.SetExtraHeaders(dict)
And v0.29.1 can't use Call and Cdp.Object anymore?
from rod.
Check my previous comment, it's type-safe now, that's the new way to use the low-level API, cdp.Object
is not type-safe.
If you really want to use raw json, you can do something like:
// Or even more lower way to use raw json to send request to chrome.
ctx, client, sessionID := page.CallContext()
client.Call(ctx, sessionID, "Network.SetCookie", map[string]string{
"name": "rod",
"value": "test",
"url": "https://github.com",
})
vs
proto.NetworkSetCookie{
Name: "rod",
Value: "test",
URL: "https://github.com",
}.Call(page)
These two ways are the same.
from rod.
with map[string]string
you have to write more code.
SetHeaders(map[string]string{"a": "b"})
vs
SetHeaders("a", "b")
The later is obviously shorter. When you have multiple pairs, you can do:
SetHeaders(
"key1", "value1",
"key2", "value2",
)
from rod.
Thanks for your report. The v0.30.1
added the HandleAuth
helper to deal with your problem.
I tested with mitmproxy --showhost --proxyauth a:b
, it works well.
Here's the example to use it:
https://github.com/ysmood/rod/blob/3ae35ce463f28e3ce8055e6dafda5eb33f39fc53/browser_test.go#L70
from rod.
@zjlx about the breaking change issue, check this answer: How versioning is handled
from rod.
Thanks for your report. The
v0.30.1
added theHandleAuth
helper to deal with your problem.I tested with
mitmproxy --showhost --proxyauth a:b
, it works well.Here's the example to use it:
https://github.com/ysmood/rod/blob/3ae35ce463f28e3ce8055e6dafda5eb33f39fc53/browser_test.go#L70
Thank you so much for the changes. It is working well.
from rod.
Related Issues (20)
- Is it possible to improve Screenshot's fullPage implementation? HOT 1
- Why doesn't it remember the window size now? HOT 11
- Bug Select Frame Element HOT 2
- Bug element's pointer-events is none HOT 4
- Download in headless mode is failing, but works fine otherwise HOT 6
- Dear go-rod production team, I would like to ask you a question about remote connections and using proxies. HOT 3
- Is there a way to get css rules associated with an element ? HOT 2
- Add a JS script to browser HOT 3
- Missing Request Body When Loading "https://www.booking.com" Using go-rod HOT 2
- [bug] Page.EachEvent call is not reusable for the second time HOT 2
- but cannot check the element nodes on go-rod. HOT 5
- I have a print button on UI, on clicking that the print dialog box doesn't open in browser launched from rod. HOT 6
- Is there any way to wait for a certain element in the page: HOT 5
- Any way to launch multiple browsers with different users each? HOT 1
- Exporting the full page as PDF (single page) HOT 1
- Ignoring the error "element's pointer-events is none" HOT 2
- θΏη¨ε―ε¨θ’«ζε ζ ζ³ιεΊ ε―Όθ΄ιζ» HOT 3
- Upload file on Managed Launcher? HOT 2
- Does rod support separate sessions or incognito mode? HOT 2
- if err == nil εηι»θΎδΈδΌζ§θ‘ HOT 1
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.