Where does jsdom download resources?
I'm working with Node.js and jsdom to find and download all the css/js/images on a page, and then rewrite the urls to be relative (like wget --page-requisites --convert-links). But I'm wondering if I even have to do all that work if jsdom already fetches resources. If I turn on FetchExternalResources, then what does jsdom do with them? Are they stored in memory somewhere that I can save them to disk?
require('jsdom').defaultDocumentFeatures = {
FetchExternalResources : ['script', 'css', 'link', 'img'],
ProcessExternalResources : true,
Mutatio开发者_JS百科nEvents : false,
QuerySelector : false
}
jsdom currently only fetches javascript and keeps it in memory. If you'd like to fetch other assets you will need to bake in that functionality. You could for instance: doc.getElementsByTagName('img')
, loop through them, fetch, and store the images to disk.
精彩评论