Php simple_html_dom找不到我的元素

Php simple_html_dom找不到我的元素,php,simple-html-dom,Php,Simple Html Dom,我正试着用亚马逊的价格来做练习 <?php require('simple_html_dom.php'); $get = $_GET['id']; $get_url = 'http://www.amazon.co.uk/s/field-keywords='.$get; echo $get_url; // Retrieve the DOM from a given URL $html = file_get_

我正试着用亚马逊的价格来做练习

      <?php
      require('simple_html_dom.php');
      $get = $_GET['id'];
      $get_url = 'http://www.amazon.co.uk/s/field-keywords='.$get;
       echo $get_url;
      // Retrieve the DOM from a given URL
      $html = file_get_html($get_url);

      foreach($html->find('li[class=newp]') as $e) 
        echo $e->plaintext . '<br>';

您的代码很好。很可能是您的PHP设置造成的

在php脚本的开头,查看它是否打印出任何有用的错误

另外,请注意,simple_html_dom在内部使用
file_get_contents()
函数获取页面内容。因此,您可能需要运行
file\u get\u contents($get\u url)
来查看发生了什么

如果该函数不起作用,那么它肯定是您的PHP设置。在这种情况下,我建议在标题中用这个问题开始另一个线程

不过,这可能会有所帮助:

这里没问题。我得到了结果。您正在使用什么
id
?(我使用URL
http://www.amazon.co.uk/s/field-keywords=11
)我正在使用blacklist@Rik用这个foreach($html->find('li[class=newp]')作为$e)你得到了结果吗?用你的确切代码我得到了id=blacklist()的结果。很好。这里的类仍然称为“newp”,因此您应该检查本地化、浏览器版本或其他内容。也许是用户代理字符串Amazon检查并给出不同的结果。
error_reporting(E_ALL);
ini_set('display_errors', '1');