Answer the question
In order to leave comments, you need to log in
How to force nodejs to execute in nwjs application?
Good afternoon.
I'm trying to make a desktop application on nwjs and ran into one problem.
After loading the page into the application window, I try to download the image, and if I load a local html page, then using the node it turns out to save the image to disk, but if I try to load a site from the web with identical content into the application window, saving does not occur.
manifest.json:
....
"main": "/здесь локальный путь/saveimg.html",
// "main": "http://site.com", //при этой точке входа не хочет работать с содержимым
"inject-js-end": "test.js",
...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div id="imgid" class="imgclass">
<img id="imgimg" src="http://cs631122.vk.me/v631122037/5952/retsE5oGX9w.jpg" alt="">
</div>
</body>
</html>
var fs = require('fs');
var request = require('request');
var img = document.querySelector('div#imgid>img');
console.log(img);
var url=img.src;
console.log(url);
request(url).pipe(fs.createWriteStream('opa.jpg'));
Answer the question
In order to leave comments, you need to log in
Why do it through the site? Let the site return a list of URLs, and the program will request and download them. The fact that it is impossible to connect node modules from the site is quite logical. Maybe it's some kind of security restriction in nwjs
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question