Esempio n. 1
0
function tags_text($selector, $source = false)
{
    $r = array();
    foreach (nodes($selector, $source) as $node) {
        $text = trim(node_text($node));
        if (!$text) {
            $text = $node->GetAttribute('content');
        }
        if ($text) {
            $r[] = $text;
        }
    }
    re($r);
    return $r;
}
function extractPages($url)
{
    $dom = new DOMDocument();
    $dom->loadHTMLFile($url);
    download($url, BUILD_DIR . '/downloaded-pages/toc.html');
    $h3s = nodes($dom, 'h3');
    foreach ($h3s as $h3) {
        $links = $h3->getElementsByTagName('a');
        if ($links->length) {
            $pages[] = (object) array('name' => $h3->textContent, 'url' => $links->item(0)->getAttribute('href'), 'sections' => extractSections($h3));
        }
    }
    return $pages;
}