Answer the question
In order to leave comments, you need to log in
How to parse ads having a list of links to these ads?
Suppose there is such a page: www.farpost.ru/vladivostok/auto/sell_spare_parts/+... It has a list of links to specific ads that need to be parsed. Using this code, we get a list of the necessary ads:
<?php
require_once('simple_html_dom.php');
$maxpost = '100'; // к-во постов
$html = file_get_html('http://www.farpost.ru/vladivostok/auto/sell_spare_parts/');
$i = '0';
foreach ($html->find('tr.bull-item') as $article) {
$item['link'] = $article->find('a.bulletinLink', 0)->innertext;
$articles[] = $item; // пишем в массив
$i++;
if ($i == $maxpost) break; // прерывание цикла
}
for ($j = 0; $j < $maxpost; $j++) {
echo '<div class="message">.';
echo '<p class="text">' . $articles[$j]['link'] . '</p>';
echo '</div>';
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question