I'm trying to automate the web browser
Save As action on right click on a website, that downloads the entire page including HTML, CSS and assets(png, svg, etc.).
How can this be done in Rust programmatically to perform the same action and automate it?
I have tried GitHub - Skallwar/suckit: Suck the InTernet
But it does not give quite the same output as the browser
Save As action.
The browser has a rewriting step where it uses its understanding of the full list of resources used on the page after JS executes to save all those resources to the resource folder and rewrite the paths in the HTML.
Unfortunately the Chrome remote debugging protocol only supports print-to-PDF, not the bundled download: https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF
If you think the Chrome remote debugging protocol is useful, you launch the browser doing somethng like this:
let dir = makeTempDir();
let exe = findBrowserExe().or_else("google-chrome-stable");
let cmd = Command::new(exe)
.spawn().expect("browser failed to start");
browserConn.callMethod("Network", "setCookies", json!(...));
let pageId = browserConn.callMethod("Target", "createTarget", json!(url => url))["targetId"];
(I have not checked if there's already a crate to handle the protocol. Just making stuff up in the 2nd part.)
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.