Beispiel #1
0
<?php

include '../funciones/DB.php';
getSubcategorias();
function getSubcategorias($url)
{
    $doc = phpQuery::newDocumentHTML(fetch($url));
    phpQuery::selectDocument($doc);
    foreach (pq('.listc li h2 a') as $el) {
        $url = 'http://www.pac.com.ve' . pq($el)->attr('href');
        if (strpos($url, '&ubicacion=')) {
            $href = substr($url, 0, strpos($url, '&ubicacion='));
        } else {
            $href = $url;
        }
        echo 'LINEA ' . __LINE__ . ': ' . $url . "\n";
        echo 'LINEA ' . __LINE__ . ': ' . $href . "\n";
        $subcategorias[] = array('name' => pq($el)->text(), 'url' => $href, 'childrens' => getSubcategorias($href));
    }
    return isset($subcategorias) ? $subcategorias : null;
}