Get all javascript or css resources of the same-origin
and0x00 opened this issue · comments
Rod Version: v0.114.8
Hi. Is there any way to list the JavaScript and CSS resources loaded by the browser when accessing the site using the frames as shown in the print or the sources?
- Assuming that I do not want to do any kind of web scraping under any circumstances
![Screenshot 2024-04-12 at 22 39 32](https://private-user-images.githubusercontent.com/90927438/322167704-b1f20030-190c-48ae-82d6-1d22b6755dc8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTU4MzUyNjMsIm5iZiI6MTcxNTgzNDk2MywicGF0aCI6Ii85MDkyNzQzOC8zMjIxNjc3MDQtYjFmMjAwMzAtMTkwYy00OGFlLTgyZDYtMWQyMmI2NzU1ZGM4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA1MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNTE2VDA0NDkyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFhN2Y0MzgyNGE4YWE2NTcyNTMzZWQ3ZDBjMmYyNWNhYWVlNDc2MjhhYTQ5YWUzMTZkYmQ3OWYxYjRiYzE2N2YmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.9d20aa7o5S0vuo2Blnu759bqxGl9W7If1wUod9oBiyE)
I tried it this way, but only the URLs of resources from other domains are printed. I would like it to also show the local resources.
var e proto.NetworkResponseReceived
wait := page.WaitEvent(&e)
page.MustNavigate(URL).MustWaitLoad().MustWaitDOMStable().MustWaitStable()
wait()
xhrURLs := make([]string, 0)
go page.EachEvent(func(e *proto.NetworkRequestWillBeSent) {
if e.DocumentURL != "" {
if e.Type == proto.NetworkResourceTypeXHR || e.Type == proto.NetworkResourceTypeFetch {
fmt.Printf("%v\n", e.Request.URL)
// xhrURLs = append(xhrURLs, e.Request.URL)
}
if e.Type == proto.NetworkResourceTypeScript || e.Type == proto.NetworkResourceTypeStylesheet {
fmt.Printf("%v\n", e.Request.URL)
}
if e.Type == proto.NetworkResourceTypeDocument {
fmt.Printf("%v\n", e.Request.URL)
}
}
})()
You must listen to the event before navigating
That worked!!! Thank you very much!!!
Please add a valid Rod Version: v0.0.0
to your issue. Current version is v0.115.0
Please fix the format of your markdown:
3:163 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]
7:1 MD033/no-inline-html Inline HTML [Element: img]
generated by check-issue