domparser — PHP Simple HTML DOM Parser не может найти элементы после использования str_get_html ();

Я использую PHP Simple HTML DOM Parser для сбора текста с другого сайта. Когда я использую file_get_html ($ url), я получаю сообщение об ошибке: «Message: file_get_contents (http://www.yellowbook.com/profile/great-wall-restaurant_1855353442.html): не удалось открыть поток: ошибка HTTP-запроса! HTTP / 1.1 416 Запрошенный диапазон не удовлетворяется «

Поэтому я могу использовать str_get_html ($ url), и я получаю возврат, но потом не могу найти никаких элементов. Вот мой код:

$data['yb_data_reviews'] = '';
$yb_reviews[] = '';
$yb_url = 'http://www.yellowbook.com/profile/great-wall-restaurant_1855353442.html';
if($yb_url){
$yb_dom = str_get_html($yb_url);
foreach($yb_dom->find('div.detailItem') as $yb_review) {
$item['author'] = $yb_review;
$yb_reviews[] = $item;
}
$data['yb_data_reviews'] = $yb_reviews;
}
print_r($data['yb_data_reviews']);

Мое возвращение пустое. Если я просто верну $ yb_dom, я получу:

simple_html_dom Object ( [root] => simple_html_dom_node Object ( [nodetype] => 5 [tag] => root [attr] => Array ( ) [children] => Array ( ) [nodes] => Array ( [0] => simple_html_dom_node Object ( [nodetype] => 3 [tag] => text [attr] => Array ( ) [children] => Array ( ) [nodes] => Array ( ) [parent] => simple_html_dom_node Object *RECURSION* [_] => Array ( [4] => http://www.yellowbook.com/profile/great-wall-restaurant_1855353442.html ) [tag_start] => 0 [dom:simple_html_dom_node:private] => simple_html_dom Object *RECURSION* ) ) [parent] => [_] => Array ( [0] => -1 [1] => 2 ) [tag_start] => 0 [dom:simple_html_dom_node:private] => simple_html_dom Object *RECURSION* ) [nodes] => Array ( [0] => simple_html_dom_node Object ( [nodetype] => 5 [tag] => root [attr] => Array ( ) [children] => Array ( ) [nodes] => Array ( [0] => simple_html_dom_node Object ( [nodetype] => 3 [tag] => text [attr] => Array ( ) [children] => Array ( ) [nodes] => Array ( ) [parent] => simple_html_dom_node Object *RECURSION* [_] => Array ( [4] => http://www.yellowbook.com/profile/great-wall-restaurant_1855353442.html ) [tag_start] => 0 [dom:simple_html_dom_node:private] => simple_html_dom Object *RECURSION* ) ) [parent] => [_] => Array ( [0] => -1 [1] => 2 ) [tag_start] => 0 [dom:simple_html_dom_node:private] => simple_html_dom Object *RECURSION* ) [1] => simple_html_dom_node Object ( [nodetype] => 3 [tag] => text [attr] => Array ( ) [children] => Array ( ) [nodes] => Array ( ) [parent] => simple_html_dom_node Object ( [nodetype] => 5 [tag] => root [attr] => Array ( ) [children] => Array ( ) [nodes] => Array ( [0] => simple_html_dom_node Object *RECURSION* ) [parent] => [_] => Array ( [0] => -1 [1] => 2 ) [tag_start] => 0 [dom:simple_html_dom_node:private] => simple_html_dom Object *RECURSION* ) [_] => Array ( [4] => http://www.yellowbook.com/profile/great-wall-restaurant_1855353442.html ) [tag_start] => 0 [dom:simple_html_dom_node:private] => simple_html_dom Object *RECURSION* ) ) [callback] => [lowercase] => 1 [original_size] => 71 [size] => 71 [pos:protected] => 71 [doc:protected] => http://www.yellowbook.com/profile/great-wall-restaurant_1855353442.html [char:protected] => [cursor:protected] => 2 [parent:protected] => simple_html_dom_node Object ( [nodetype] => 5 [tag] => root [attr] => Array ( ) [children] => Array ( ) [nodes] => Array ( [0] => simple_html_dom_node Object ( [nodetype] => 3 [tag] => text [attr] => Array ( ) [children] => Array ( ) [nodes] => Array ( ) [parent] => simple_html_dom_node Object *RECURSION* [_] => Array ( [4] => http://www.yellowbook.com/profile/great-wall-restaurant_1855353442.html ) [tag_start] => 0 [dom:simple_html_dom_node:private] => simple_html_dom Object *RECURSION* ) ) [parent] => [_] => Array ( [0] => -1 [1] => 2 ) [tag_start] => 0 [dom:simple_html_dom_node:private] => simple_html_dom Object *RECURSION* ) [noise:protected] => Array ( ) [token_blank:protected] => [token_equal:protected] => =/> [token_slash:protected] => /> [token_attr:protected] => > [_charset] => UTF-8 [_target_charset] => UTF-8 [default_br_text:protected] => [default_span_text] => [self_closing_tags:protected] => Array ( [img] => 1 [br] => 1 [input] => 1 [meta] => 1 [link] => 1 [hr] => 1 [base] => 1  => 1 [spacer] => 1 ) [block_tags:protected] => Array ( [root] => 1 [body] => 1 [form] => 1 [div] => 1 [span] => 1 [table] => 1 ) [optional_closing_tags:protected] => Array ( [tr] => Array ( [tr] => 1 [td] => 1 [th] => 1 ) [th] => Array ( [th] => 1 ) [td] => Array ( [td] => 1 ) [li] => Array ( [li] => 1 ) [dt] => Array ( [dt] => 1 [dd] => 1 ) [dd] => Array ( [dd] => 1 [dt] => 1 ) [dl] => Array ( [dd] => 1 [dt] => 1 ) [p] => Array ( [p] => 1 ) [nobr] => Array ( [nobr] => 1 ) [b] => Array ( [b] => 1 ) [option] => Array ( [option] => 1 ) ) )

Что я делаю неправильно, что я не могу вернуть какие-либо элементы с помощью str_get_html ()? Любая помощь приветствуется. Благодарю.

2

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]