Answer the question
In order to leave comments, you need to log in
Php, DiDom parser. How to display href?
Good, I began to study this "wonderful" parser and faced the fact that the cat cried on the Internet of examples.
I'm looking for help from a guru on this parser.
Actually what is
Parsim a certain site.
We receive the list of all div, class=links
And how now in found to receive all links?
I do:$document = new Document('некий сайт', true);
$r_div=$document->find('div[class="links"]');
foreach($r_div as $div)
{
$track=$div->find('a[class="track-more-info"]');
}
echo $document->html();
echo $track->html();
Fatal error: Call to a member function html() on a non-object
Answer the question
In order to leave comments, you need to log in
based on the "documentation" Imangazaliev / DiDOM
should work like this:
or
$track->attr('href');
$track->getAttribute('href');
foreach($r_div as $div) { $track=$div->find('a[class="track-more-info"]'); }
$track
result is an array with the found elements, a[class="track-more-info"]
foreach ($track as $item) {
echo $item->href;
}
$list = $div->find('a[class="track-more-info"]');
$track = array_shift($list);
if (!empty($track)) {
echo $track->href;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question