Comments (3)
Please add a valid Rod Version: v0.0.0
to your issue. Current version is v0.114.5
generated by check-issue
from rod.
package main
import (
"fmt"
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/launcher"
"github.com/go-rod/rod/lib/proto"
"time"
)
func main() {
url := launcher.New().Headless(false).MustLaunch()
browser := rod.New().ControlURL(url).MustConnect()
page := browser.MustPage("")
go func() {
page.EachEvent(func(e *proto.NetworkRequestWillBeSent) {
fmt.Printf("Request: %s %s\n", e.Request.Method, e.Request.URL)
}, func(r *proto.NetworkResponseReceived) {
//How do I get the contents of the body here
//m := proto.NetworkGetResponseBody{RequestID: r.RequestID}
//r, _ = m.Call(page)
})()
}()
time.Sleep(3 * time.Second)
page.MustNavigate("https://www.baidu.com")
select {}
}
How do I get the contents of the body here
from rod.
I hope it helps others
package main
import (
"fmt"
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/launcher"
"github.com/go-rod/rod/lib/proto"
"time"
)
func main() {
url := launcher.New().Headless(false).MustLaunch()
browser := rod.New().ControlURL(url).MustConnect()
page := browser.MustPage("")
go func() {
page.EachEvent(func(e *proto.NetworkRequestWillBeSent) {
fmt.Printf("Request: %s %s\n", e.Request.Method, e.Request.URL)
}, func(e *proto.NetworkResponseReceived) {
reply, err := (proto.NetworkGetResponseBody{RequestID: e.RequestID}).Call(page)
if err != nil {
fmt.Println(err)
}
fmt.Println(reply.Body)
})()
}()
time.Sleep(3 * time.Second)
page.MustNavigate("https://www.baidu.com")
select {}
}
from rod.
Related Issues (20)
- Using a headed browser with a proxy causes ERR_TIMED_OUT HOT 7
- 能否添加一个打开页面后强制等待的方法 HOT 3
- MustClick can't click the element but javascript can HOT 4
- MustWaitDownload() is not working when element a's target is set to _blank HOT 2
- Calling docker container chrome from another docker container HOT 3
- 似乎无法得到渲染数据 HOT 3
- 渲染有问题 HOT 2
- How to spawn browser singleton for reusable PagePool? HOT 6
- How can I use $$ or $ helpers in the page.MustElementByJS() method? HOT 1
- 如何处理选择证书弹窗? HOT 5
- Rod Docker 如何监听浏览器存活状态 HOT 2
- Get ws connection string from managed go-rod remote instance. HOT 3
- Stealth not work after v0.106.0. HOT 1
- Get browser console errors HOT 4
- Avoid panicking if a bad regexp is returned when hijacking using an incorrect pattern HOT 1
- page.ElementR returns fake element
- 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
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.