Warning: file_put_contents(/datas/wwwroot/jiajiahui/core/caches/caches_template/2/default/show.php): failed to open stream: Permission denied in /datas/wwwroot/jiajiahui/core/libraries/classes/template_cache.class.php on line 55

Warning: chmod(): Operation not permitted in /datas/wwwroot/jiajiahui/core/libraries/classes/template_cache.class.php on line 56
如何从节点j中的给定url获取文档对象 - 源码之家

如何从节点j中的给定url获取文档对象

问题描述:

如何仅使用Node.js API获取给定URL的文档以使用。 这里是我想出的一个片段:如何从节点j中的给定url获取文档对象

var needHttp = require('http'); 

var getAllFromSite = function (siteUrl, tag) 
{ 

var requestToURL = needHttp.get(siteUrl, function (responseFromURL) { 

responseFromURL. SOMEHOWgetDOCUMENT... 
    }); 

} 
+0

[读数可能的复制内容从URL与Node.js](https://*.com/questions/6287297/reading-content-from-url-with-node-js) – lumio

到目前为止,我发现这一点,但它仍然需要的DOMParser,我便无法找到:

function getSourceAsDOM(url) 
{ 
xmlhttp=new XMLHttpRequest(); 
xmlhttp.open("GET",url,false); 
xmlhttp.send(); 
parser=new DOMParser(); 
return parser.parseFromString(xmlhttp.responseText,"text/html"); 
}