Given an url (e.g. localhost:8000
), how can a script find what resources will a browser load (via HTTP requests)?
For example, let's suppose that the /
route responds with:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
some content
<img src="/foo.png" alt="">
</body>
</html>
The resources which will be loaded are:
/css/style.css
foo.png
This is simple (just a dom iteration with via cheerio
or so), but it's not so native I think it should.
An iteration in the response HTML will not work for the additional CSS @import
s and background-image
and so on.
What is the native way to get the list with the CSS, images and maybe other resources which are loaded by the browser?
Maybe is it possible via jsdom
?