用nodejs保存网站 [英] save website with nodejs

查看:154
本文介绍了用nodejs保存网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

如何保存任何网站的所有资源(图像,文本文件,json文件,css ...)?

我必须使用nodejs代码

感谢您的帮助!

Hi all,

how can i save all resources (images, text files, json files,css ... ) of any website ?

i must use nodejs code

thank for help !

推荐答案

在这里,看看:
如何将对象保存到Node.js中的文件? [ ^ ]

要将对象序列化为JSON字符串,请执行以下操作:
Here, have a look:
How can I save objects to files in Node.js?[^]

To serialize your objects to a JSON string:
var str = JSON.stringify(object)


将其作为对象读回. (该字符串可以写入文件):


To read it back as an object. (The string can be written to file):

var obj = JSON.parse(string)


例如这样的对象:


For example an object like this:

var p = new Foo();
p.Bar = "Terry"
var s = JSON.stringify(p)
// write s to file, get => { "Bar" : "Terry" }
// read s from file and turn back into an object:
var p = JSON.parse(s);



此外,这是一个有趣的内容: NodeJS和回调 [



Further, this is an interesting read: NodeJS and Callbacks[^]


这篇关于用nodejs保存网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆