简体   繁体   中英

http request by node-red with execution the stript

I would like ask, When I use node http request from Node-red for request to any page it returned me whole page like

msg.payload="<'html>
<'script>
function A;
function B;
window.onload = function() {...
etc...
<'/script>
<'body>
<'table>"

How can I execute the functions from the script? So how it could return executed page to node-red? I mean, I need the results from the fucntions and I get just function in payload, so I don't know how could I execute function which are in payload.

Thank you Pavol

The short answer is, you don't.

Running JavaScript embedded in a web page needs all the things a browser provides to the page, eg the DOM model these are just not there in the Node-RED runtime.

If you want to load and render a page then you need to look at something like node-red-contrib-nbrowser that will run the page in a virtual browser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM