如何通过php将当前网页内容保存到word中

发布于 2024-10-06 19:26:21 字数 390 浏览 0 评论 0原文

我需要将网页内容保存在word上。我也需要保留链接和格式。如果我发送,

$ter=$ter. "<a href='$url'>".$chunk."</a> ";
 $fp  =  fopen("test.doc",  'w+'); 
        $str  =  $ter;

        fwrite($fp,  $str); 

        fclose($fp);

我会得到一个Word文档,但我失去了链接..它的结果是

a href='http://www.google.com/search?q=sells+sea+shells%0D%0A'>sells sea shells

i need to save contents of webpage on word. i need to keep the links and formating too. if i send

$ter=$ter. "<a href='$url'>".$chunk."</a> ";
 $fp  =  fopen("test.doc",  'w+'); 
        $str  =  $ter;

        fwrite($fp,  $str); 

        fclose($fp);

i get a word document but i loose the links ..it comes out as

a href='http://www.google.com/search?q=sells+sea+shells%0D%0A'>sells sea shells

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苍暮颜 2024-10-13 19:26:21

与这个奇怪的假装“.doc”文件一起使用,Word (2007) 确实似乎将其显示为文档;如果我改变你的 fwrite 行:

fwrite($fp,  '<html><body>' . $str . '</body></html>');

它有效。

Going along with this weird pretend ".doc" file which Word (2007) does seem to display as a document; if I change your fwrite line:

fwrite($fp,  '<html><body>' . $str . '</body></html>');

It works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文