开发者

Save document in PHP simple HTML DOM

I have a problem with PHP simple HTML DOM.

The following to save the code in a text document ...

<?php 
include('simple_html_d开发者_开发知识库om.php');
$a= file_get_html('http://web.com');
$a->save('text.txt');
?>

But only the first time creates it, if I try to update it appears not to overwrite

What could be the problem?

EDIT: the text file that is created is not updated when I run the PHP.

The website does change.


When you expect the output file to change, are you:

  1. Reloading the modified webpage $a = file_get_html('http://web.com');
  2. Modifying the object $a directly

If you are not doing 2), then as Marc B suggests, do not use simplehtmldom.
If you are doing 1), output $a, var_dump($a); as a first step to ensure that the object was actually modified.


yes, it is not changed becouse nothing else has also changed, in particular http ://web.com


Why use simplehtmldom for this? It's massive overhead just to write out a file.

<?php
    file_put_contents('test.txt', file_get_contents('http://web.com'));

would accomplish the same thing

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜