如何使用php或java脚本将网页保存为文本文件 [英] how to save a web page in text file using php or java script

查看:71
本文介绍了如何使用php或java脚本将网页保存为文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用PHP或JavaScript自动将网页保存为文本文件.

I want to save a web page in a text file, automatically by using PHP or JavaScript

推荐答案

我不使用PHP(我认为是是垃圾),所以我等着看你是否能得到更好的答案,但是....

javascript不会为您保存文件,它不会那样做.您没有说是否要保存完整的HTML或某种形式的文本表示,而是通过设置响应的标头告知浏览器它是附件来使浏览器保存文件,然后您可以将您想要的任何文本下推到浏览器.
I don''t do PHP ( I think it''s rubbish ), so I waited to see if you''d get a better answer, but....

javascript isn''t going to save a file for you, it doesn''t do that. You don''t say if you want to save the full HTML, or some sort of text representation, but you make the browser save a file by setting the header for the response to tell it that it''s an attachment, then you can push whatever text you want down to the browser.


您是要保存发送到浏览器的输出吗?

您可以使用输出缓冲 [此提示/技巧 [
Do you mean save the output which is sent to the browser?

You can do this using Output Buffering[^] and saving the buffer as a text file.

This Tip/Trick[^] shows how to save the output.


这篇关于如何使用php或java脚本将网页保存为文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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