The ring-around-a-rosey has ended up here!
Simply cannot find any concrete examples on how to interface with these "Network Events Types" and would appreciate some sample code and/or direction.
EventNetworkDataReceived = "Network.dataReceived"
EventNetworkEventSourceMessageReceived = "Network.eventSourceMessageReceived"
EventNetworkLoadingFailed = "Network.loadingFailed"
EventNetworkLoadingFinished = "Network.loadingFinished"
EventNetworkRequestIntercepted = "Network.requestIntercepted"
EventNetworkRequestServedFromCache = "Network.requestServedFromCache"
EventNetworkRequestWillBeSent = "Network.requestWillBeSent"
EventNetworkResourceChangedPriority = "Network.resourceChangedPriority"
EventNetworkResponseReceived = "Network.responseReceived"
EventNetworkWebSocketClosed = "Network.webSocketClosed"
EventNetworkWebSocketCreated = "Network.webSocketCreated"
EventNetworkWebSocketFrameError = "Network.webSocketFrameError"
EventNetworkWebSocketFrameReceived = "Network.webSocketFrameReceived"
EventNetworkWebSocketFrameSent = "Network.webSocketFrameSent"
EventNetworkWebSocketHandshakeResponseReceived = "Network.webSocketHandshakeResponseReceived"
EventNetworkWebSocketWillSendHandshakeRequest = "Network.webSocketWillSendHandshakeRequest"
I'm seeing lots of references to a Listen function but can't seem to find it's implementation.
I'm sure I'm not the only one that would benefit from this and it would make a welcomed addition the Examples code.
Thanks 馃憤
I also found this problem. won't anyone help us?
We can only hope!
@millken Check this alternative project out, I'm using this now -- it has a clean/simple interface a lot like Puppeteer with Network Events baked in as simple CallBacks : https://github.com/raff/godet
@kenshaw, Could you please help with small example?
First you need to uncomment network.Enable(); to start receiving network events in https://github.com/chromedp/chromedp/blob/master/handler.go#L104
Then you need to act on the events in processEvent in https://github.com/chromedp/chromedp/blob/master/handler.go#L225
Look how Page and DOM events are handled there and try to work it out with Network.
I am sorry but I do not have any complete example.
@milesich I don't think it's as easy as that -- it still would be nice if the codebase had these events baked in as a bonafide feature.
In the meantime I think ppl should take a look at: https://github.com/mkenney/go-chrome
It's a lot more feature rich, easy to use api and fast!
馃憤
If anyone is still interested, I hacked together small changes in the lib on my forked repo to intercept network events.
need help!!???!???
i added a CallbackFunc method for it, add a map[string]func(interface{}) for targetHandle struct
u can add callback function like
cdp.Callback("method",func (interface{}){})
only page ,network ,dom, u can add the other event callback listener as u like
maybe u can try it here
https://github.com/m4p1e/chromedp
Thanks all for the input. We're currently designing v2, where the API and internal design may change. We also plan to add better documentation and more examples. Until that version is finished, we'd like to hold off on adding features to v1, to minimize the risk for regressions.
There already are some ideas of what this could look like; for example, see #251. Stay tuned for v2.
For those wondering what happened here, this was finished a while ago, and the APIs for listening to target (tab) and browser events are at https://godoc.org/github.com/chromedp/chromedp#ListenTarget and https://godoc.org/github.com/chromedp/chromedp#ListenBrowser, respectively.
Hi @mvdan
I was wondering, If there's a clean way to sniff network events, because it seems they are set to private...
For example:
network.responseReceived
Most helpful comment
We can only hope!