无法获取分页页面的DOMDocument的内容-DOMXpath PHP

时间:2019-02-14 13:55:30

标签: php parsing domdocument domxpath

在我的代码中,这始终为我提供首页内容。我知道分页参数之前的页面加载。我如何获得正确的内容。我应该怎么做才能找到正确的解决方案?

for ($page=1; $page<3500; $page++) {

    $doc = new \DOMDocument();
    @$doc->loadHTMLFile("https://steamcommunity.com/market/search?appid=730#p".$page."_popular_desc");
    $xpath = new \DOMXPath($doc);
    $elements = $xpath->query('//span[@class="market_listing_item_name"]');

    $array = iterator_to_array($elements);
    $newArr = array();
    foreach ($array as $arr) {
        $newArr[] = array(
            "itemName" => $arr->textContent
        );
    }
}

0 个答案:

没有答案