【发布时间】:2016-06-11 15:10:57
【问题描述】:
我想使用网站的内容并将它们包含在我的 "Simple Html DOM" 中,不幸的是,通常适用于其他网站的代码在这种特定情况下失败:
<?php
// Note you must download the php files from the link above
// and link to them on this line below.
include_once('simple_html_dom.php');
$html = file_get_html('http://www.comelmar.it/index.aspx?idmnu=23&midx=3&mbidx=2&idmnub=8&Lang=EN');
$elem = $html->find('table[class=Descrizione]', 0);
echo $elem;
?>
警告: file_get_contents(http://www.comelmar.it/index.aspx?idmnu=23&midx=3&mbidx=2&idmnub=8&Lang=EN) [function.file-get-contents]:无法打开流:HTTP 请求 失败的! HTTP/1.1 500 内部服务器错误 public_html/elin-custom-code/simple_html_dom.php 上 第 75 行
致命错误:在非对象上调用成员函数 find() public_html/elin-custom-code/sklad-1.php 第 9 行
【问题讨论】:
-
看起来页面需要用户代理什么的。它抛出一个 500,这意味着有一个错误。你的
Fatal error是因为$html是假的。