Привет, я хочу извлечь конкретный класс div только с определенного сайта.
Вот что у меня есть, но по какой-то причине это не работает, я получаю кучу ошибок ::
$page = file_get_contents('https://extcall.17track.net/en/track#apitype=1&nums=RK444760227FR');
$doc = new DOMDocument();
$doc->loadHTML($page);
$divs = $doc->getElementsByTagName('div');
foreach($divs as $div) {
// Loop through the DIVs looking for one withan id of "content"
// Then echo out its contents (pardon the pun)
if ($div->getAttribute('class') === 'tracklist-fill') {
echo $div->nodeValue;
}
}
что я хочу извлечь - это результаты отслеживания только без бренда, названия или других элементов
что я делаю не так?
ура
этиэто ошибки, которые я получаю
Warning: DOMDocument::loadHTML(): Tag main invalid in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Tag section invalid in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Tag section invalid in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : p in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : p in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
, и это HTML-фрагмент веб-сайта, который вы видите выше в файле, получить содержимое
body> main> div> section.yq-panel.yq-panel-tracklist.jcTrackContainer> div> div.tracklist-fill
<div class="tracklist-fill">
<div class="tracklist-ps-transit">
<div class="yqcr-ps" data-ps="10"><a class="btn btn-icon fa-PS_10 ps-bgcolor-10 waves-effect" title="In transit"
href="//help.17track.net/hc/en-us/articles/228084227#10"
yqg-events="{C:功能操作,A:结果页-查看帮助,L:包裹状态_10}" target="_blank"
data-icon=""></a>
<div data-name=""><p class="text-uppercase" title="RK444760227FR">RK444760227FR</p>
<p class="text-capitalize" title="In transit">In transit</p></div>
</div>
<div class="yqcr-transit">
<div class="from" data-key="06051">
<div class="base-info" data-carrier-type="fc">
<div><span title="France" data-country="">France</span> <i title="La Poste">La Poste</i></div>
</div>
<div class="action-info"><a class="btn btn-icon btn-pure btn-default fa-home waves-effect waves-circle"
target="_blank" href="http://www.laposte.fr/"
yqg-events="{C:功能操作,A:结果页-跳转运输商官网,L:06051}"
title="Go to the carrier's official website."> </a></div>
</div>
<div class="to" data-key="07071">
<div class="base-info" data-carrier-type="sc">
<div><span title="Greece" data-country="">Greece</span> <i title="ELTA">ELTA</i></div>
</div>
<div class="action-info"><a class="btn btn-icon btn-pure btn-default fa-home waves-effect waves-circle"
target="_blank" href="http://www.elta.gr/"
yqg-events="{C:功能操作,A:结果页-跳转运输商官网,L:07071}"
title="Go to the carrier's official website."> </a></div>
</div>
</div>
</div>
<div class="tracklist-events scrollable is-enabled scrollable-vertical" yq-data="scrollBox"
style="position: relative;">
<div class="scrollable-container" style="height: 360px; width: 909px;">
<div class="scrollable-content" style="width: 892px;">
<div class="hide"><p data-newevents="">FRANCE, DEPARTURE FROM OUTWARD OFFICE OF EXCHANGE</p>
<time data-newtime="">2018-12-11 07:15</time>
</div>
<div class="yqcr-details">
<dl class="des-block" data-from="en">
<dt><span>Destination</span> <span>: Greece</span> <span>- Tracking consuming: 958 ms</span>
</dt>
<dd class="new"><i></i>
<div>
<time>2018-12-11 07:15</time>
<p>FRANCE, DEPARTURE FROM OUTWARD OFFICE OF EXCHANGE</p></div>
</dd>
<dd class=""><i></i>
<div>
<time>2018-12-08 09:07</time>
<p>FRANCE, POSTING/COLLECTION</p></div>
</dd>
</dl>
<dl class="ori-block" data-from="fr">
<dt><span>Origin</span> <span>: France</span> <span>- Tracking consuming: 1452 ms</span></dt>
<dd class=""><i></i>
<div>
<time>2018-12-08 00:00</time>
<p>CHAMPAGNOLE, Pris en charge</p></div>
</dd>
</dl>
</div>
</div>
</div>
<div class="scrollable-bar scrollable-bar-vertical is-disabled scrollable-bar-hide" draggable="false">
<div class="scrollable-bar-handle"></div>
</div>
</div>
</div>
и это те элементы, которые я хочу видеть на картинке
https://imgur.com/ajblnNV