Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get all javascript or css resources of the same-origin #1037

Closed
and0x00 opened this issue Apr 13, 2024 · 3 comments
Closed

Get all javascript or css resources of the same-origin #1037

and0x00 opened this issue Apr 13, 2024 · 3 comments
Labels
question Questions related to rod

Comments

@and0x00
Copy link

and0x00 commented Apr 13, 2024

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

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)
			}
		}
	})()
@and0x00 and0x00 added the question Questions related to rod label Apr 13, 2024
@and0x00 and0x00 changed the title Get all javascript or css resources (web scraping ❌) (✅ Devtools) Get all javascript or css resources of the same-origin (web scraping ❌) (✅ Devtools) Apr 13, 2024
@Fly-Playgroud
Copy link
Contributor

You must listen to the event before navigating

@and0x00
Copy link
Author

and0x00 commented Apr 15, 2024

That worked!!! Thank you very much!!!

@and0x00 and0x00 closed this as completed Apr 15, 2024
@and0x00 and0x00 changed the title Get all javascript or css resources of the same-origin (web scraping ❌) (✅ Devtools) Get all javascript or css resources of the same-origin Apr 17, 2024
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions related to rod
Projects
None yet
Development

No branches or pull requests

2 participants