file_get_contents()不适用于amazon产品网址

时间:2014-12-08 22:47:12

标签: php curl amazon-web-services amazon file-get-contents

我想从第http://www.amazon.com/gp/offer-listing/B00PCPU9D6/ref=dp_olp_new?ie=UTF8&condition=new

中获取一些数据

但是,file_get_content()无法获取此数据。我收到了以下错误。

警告:file_get_contents(http://www.amazon.com/gp/offer-listing/B00PCPU9D6/ref=dp_olp_new?ie=UTF8&condition=new)[function.file-get-contents]:无法打开流:HTTP请求失败!第5行的C:\ wamp \ www \ xx \ ajax \ testlist.php中的HTTP / 1.1 503服务不可用

当前代码:

    <?php
    $req = "http://www.amazon.com/gp/offer-listing/B00PCPU9D6/ref=dp_olp_new?ie=UTF8&condition=new";
    $html = file_get_contents($req);
    echo htmlentities($html);
    print_r($html);

    libxml_use_internal_errors( true);

    $doc = new DOMDocument;

    $doc->loadHTML( $html);

    $xpath = new DOMXpath( $doc);
    for($i=0;$i<10;$i++) 

    {

        $node = $xpath->query( '//div[@class="a-column a-span2"]//span[@class="a-size-large a-color-price olpOfferPrice a-text-bold"]')->item($i);

        $pricetxt = $node->textContent; // This will print **GET THIS TEXT**

        $pricett = substr($pricetxt,10, 11);

        $pricestr .= (float)$pricett."|";

    }

     $pricestr = rtrim($pricestr,"|");
     echo $pricestr;
    ?>

有人请帮助我..如果您有任何其他解决方案,请告诉我。

0 个答案:

没有答案