Comments (4)
Released v0.27.3
, now you have Cookies
to get the cookies directly:
https://github.com/ysmood/rod/blob/52fc1e08901b8ad7a11856c6bb888c67bc870b76/page_test.go#L33
from rod.
The best way to learn how to use a golang lib is to read its unit tests.
Here's the unit test for getting cookie: https://github.com/ysmood/rod/blob/460f5418e3eae7ac328ce32ec2b78182dc791683/page_test.go#L33
Check the titles of unit tests, you will find more examples that might be useful 😉
from rod.
@ysmood thank you for the suggestion :)
I already try that actually, and got error like this:
panic: [rod] DOMException: Failed to read the 'cookie' property from 'Document': Access is denied for this document.
at <anonymous>:1:32
{"result":{"type":"object","subtype":"error","className":"DOMException","description":"DOMException: Failed to read the 'cookie' property from 'Document': Access is denied for this document.\n at <anonymous>:1:32","objectId":"{\"injectedScriptId\":1,\"id\":3}","preview":{"type":"object","subtype":"error","description":"DOMException: Failed to read the 'cookie' property from 'Document': Access is denied for this document.\n at <anonymous>:1:32","overflow":false,"properties":[{"name":"stack","type":"accessor"},{"name":"code","type":"number","value":"18"},{"name":"name","type":"string","value":"SecurityError"},{"name":"message","type":"string","value":"Failed to read the 'cookie' property from 'Document': Access is denied for this document."}]}},"exceptionDetails":{"exceptionId":1,"text":"Uncaught","lineNumber":0,"columnNumber":31,"scriptId":"22","exception":{"type":"object","subtype":"error","className":"DOMException","description":"DOMException: Failed to read the 'cookie' property from 'Document': Access is denied for this document.\n at <anonymous>:1:32","objectId":"{\"injectedScriptId\":1,\"id\":4}","preview":{"type":"object","subtype":"error","description":"DOMException: Failed to read the 'cookie' property from 'Document': Access is denied for this document.\n at <anonymous>:1:32","overflow":false,"properties":[{"name":"stack","type":"accessor"},{"name":"code","type":"number","value":"18"},{"name":"name","type":"string","value":"SecurityError"},{"name":"message","type":"string","value":"Failed to read the 'cookie' property from 'Document': Access is denied for this document."}]}}}}
goroutine 1 [running]:
github.com/ysmood/kit/pkg/utils.E(0xc0001d2af0, 0x1, 0x1, 0x0, 0xe24b75, 0xf)
/home/widnyana/.gvm/pkgsets/go1.13.5/global/pkg/mod/github.com/ysmood/[email protected]/pkg/utils/utils.go:33 +0xab
github.com/ysmood/rod.(*Page).Eval(0xc000172000, 0xe24b75, 0xf, 0x0, 0x0, 0x0, 0x1)
/home/widnyana/.gvm/pkgsets/go1.13.5/global/pkg/mod/github.com/ysmood/[email protected]/sugar.go:232 +0xf8
long story short, I can make my snippet above works by adding code below before calling RodGetCookies
el := page.WaitLoad().Element("#topsection > div > h1")
elStable := meh.WaitStable().WaitVisible() // <-- this one
fmt.Println(elStable.Text())
closing this issue, and again thank you for creating this library, cheers! 🍻
from rod.
thank you @ysmood !
from rod.
Related Issues (20)
- 并发page pool, context deadline exceeded,page为什么没有释放? HOT 2
- Add support for Linux Arm? for downloading etc. HOT 4
- Add an initEvents public function with a Browser structure HOT 5
- page.Navigate(url), the page is like blocked HOT 1
- 测试时如何获取当前网页 HOT 5
- Click Button Eval Js Not Working HOT 4
- 获取点击后的response失败 HOT 2
- How to hide chromium command prompt HOT 2
- Element存在,但Element.MustHas却为false,检测不到Element HOT 2
- How to open a new Chrome window while using remote control HOT 4
- Using go-rod with firefox, failing to start new instance of firefox HOT 6
- How to disable the dialog when open External protocols HOT 2
- How to Set or replace response headers HOT 2
- Proxy and Hijack HOT 3
- Just a recipe to run a go-rod program as systemd service HOT 1
- How to Log CDP Logs to a File or Use slog HOT 2
- Failed to deserialize params.body - BINDINGS: binary value expected at position 61 HOT 5
- failed page screenshot in defer HOT 2
- launcher docker 是否支持常驻且直接连接 HOT 4
- Examples fail on Ubuntu 24.04 with "No usable sandbox!" HOT 8
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.