Просмотр поста

.
Vynder

Еще один простой пример. Парсим главную форума + подкатегории. Действительно, все очень удобно

<?
require_once 'phpQuery.php';

$content = file_get_contents('http://johncms.com/forum/index.php');

$document = phpQuery::newDocument($content);

$list_elements = $document->find('.list1, .list2');

foreach ($list_elements as $element)
{
    
    $pq = pq($element);

    $pq->find('.sub')->remove();
    echo '<b>'.$pq->text().'</b><br />';
    
    $forum = file_get_contents('http://johncms.com/forum/'.$pq->find('a')->attr('href'));
    $document = phpQuery::newDocument($forum);
    $list_elements1 = $document->find('.list1, .list2');
     foreach ($list_elements1 as $element1)
    {
        $pq1 = pq($element1);
        $pq1->find('.sub')->remove();
        echo $pq1->text().'<br />';
        }
}