我正在尝试从网站上获取一些内容。但我收到错误
致命错误:在第 13 行的 C:\webs\BuyersGuide_webservice\ebay_crawler_sw.php 中的非对象上调用成员函数 find()
这是代码
include_once 'simple_html_dom.php ';
$sw = $_GET['search_word']; //getting search word
$sw = str_replace(' ','+',$sw);
$url = "http://www.ebay.com/sch/i.html_trksid=p2050601.m570.l1311.R1&_nkw=".$sw."&_sacat=0&_from=R40";
$html = file_get_html($url);
$sw_c = $html->find('table[class=li rsittlref]',0);
$sw_l = $sw_c->find('a',0); //first listed hyperlink from search word
$url = $sw_l->href; //- setting target url
当我通过提供这样的静态 URL 检查我的代码时
$url="http://www.ebay.com/itm/Apple-iPhone-4S-16GB-White-Factory-Unlocked-Smartphone-/200926045964?pt=Cell_Phones&hash=item2ec820270c";
获取然后我得到正确的输出。所以抓取代码没有问题。