简单的HTML DOM问题

时间:2012-06-12 17:50:47

标签: simple-html-dom

使用Simple HTML DOM库时,我遇到了一些网站的问题。当我尝试加载以下网址http://www.t-mobile.com/shop/phones/cell-phone-detail.aspx?cell-phone=HTC-One-S-Gradient-Blue&tab=reviews#BVRRWidgetID

我的PHP代码是:

<?php

include "simple_html_dom.php";

$html=new simple_html_dom();
$url="http://www.t-mobile.com/shop/phones/cell-phone-detail.aspx?cell-phone=HTC-One-S-    Gradient-Blue&tab=reviews#BVRRWidgetID";
$html->load_file($url);
echo $html;

?>

php脚本没有错误,但每次都显示以下内容。

Unsupported Browser
It appears that you are viewing this page with an unsupported Web browser. This Web site works best with one of these supported browsers:

Microsoft Internet Explorer 5.5 or higher
Netscape Navigator 7.0 or higher
Mozilla Firefox 1.0 or higher

If you continue to view our site with your current browser, certain pages may not display correctly and certain features may not work properly for you.

有什么问题?简单的HTML DOM有限制吗?有没有其他方法可以解决这个问题?

3 个答案:

答案 0 :(得分:1)

某些网站不允许直接废弃其内容。

您可以使用 curl 获取html内容,然后使用dom对象的load()。

我希望它适合你。

答案 1 :(得分:1)

只需在simple_html_dom请求中设置您的USERAGENT:

# Creating useragent array
$useragent = array("http" => "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6");

# Creating a line from array
$useragent = stream_context_create($useragent);

# Starting Simple_HTML_Dom with our useragent
$html = file_get_html($urlCategory, $useragent)

因此,我们的请求将来自较新的浏览器而不是您的。

答案 2 :(得分:0)

设置useragent

xlwkbOutput.Sheets("Sheet1").Activate


    With ActiveSheet
    lastRow = .Cells(.Rows.Count, "F2").End(xlDown)
    End With