简体   繁体   English

为什么PHP Simple HTML DOM分析器无法从某些URL捕获标记的内容?

[英]Why is PHP Simple HTML DOM Parser unable to capture the contents of a tag from certain URL's?

I'm using PHP Simple HTML DOM Parser to get the contents of the first <h1> tag on different webpages. 我正在使用PHP Simple HTML DOM解析器来获取不同网页上第一个<h1>标记的内容。 The script works great most of the time, but on some webpages my script just kind of 'hangs up'. 该脚本在大多数情况下都运行良好,但是在某些网页上,我的脚本只是“挂断”了。 The script stops, without completing the code that comes after what I have listed below. 脚本停止了,没有完成下面列出的代码。 I looked at the source for the pages that don't work, but there is nothing particularly different about the <h1> or its contents. 我查看了无法使用的页面的来源,但是<h1>或其内容没有什么特别的不同。 Is there a way I can get this to work for all possible URL's, and if not, how can I fix my script so it won't hang up for the URL's that don't work? 有没有一种方法,我能得到这个对所有可能的URL的工作,如果没有,我怎么能解决我的脚本,所以它不会挂断为URL的不工作?

include_once( 'simple_html_dom.php');
$html = file_get_html($webpage);
$element = $html->find('h1', 0);
$element = strip_tags($element);

我从来没有得到回应,但它似乎答案是使用卷曲来获取URL的内容,然后得到用PHP简单的HTML DOM解析器的标签信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM