src/BodyParser.php
public function extractLinks()
    {
        if ($this->extractedLinks) {
            return $this->extractedLinks;
        }

        if (!is_html($this->body)) {
            return [];
        }

        $libxmlPreviousState = libxml_use_internal_errors(true);

        $dom = new DOMDocument;
        $dom->loadHTML($this->body);

        libxml_clear_errors();
        libxml_use_internal_errors($libxmlPreviousState);

        $links = [];

        foreach ($this->tags as $tag => $attribute) {
            foreach ($dom->getElementsByTagName($tag) as $element) {
                $link = $element->getAttribute($attribute);

                if (!$link) {
                    continue;
                }

                $links[] = clean_url(url_to_absolute($this->url, $link), true, true);
            }
        }

        return $this->extractedLinks = array_unique($links);
    }
public function extractLinks()
    {
        if ($this->extractedLinks) {
            return $this->extractedLinks;
        }

        if (!is_html($this->body)) {
            return [];
        }

        $libxmlPreviousState = libxml_use_internal_errors(true);

        $dom = new DOMDocument;
        $dom->loadHTML($this->body);

        libxml_clear_errors();
        libxml_use_internal_errors($libxmlPreviousState);

        $links = [];

        foreach ($this->tags as $tag => $attribute) {
            foreach ($dom->getElementsByTagName($tag) as $element) {
                $link = $element->getAttribute($attribute);

                if (!$link) {
                    continue;
                }

                $links[] = clean_url(url_to_absolute($this->url, $link), true, true);
            }
        }

        return $this->extractedLinks = array_unique($links);
    }
public function extractLinks ( ) { if ( $ this -> extractedLinks ) { return $ this -> extractedLinks ; } if ( ! is_html ( $ this -> body ) ) { return [ ] ; } $ libxmlPreviousState = libxml_use_internal_errors ( true ) ; $ dom = new DOMDocument ; $ dom -> loadHTML ( $ this -> body ) ; libxml_clear_errors ( ) ; libxml_use_internal_errors ( $ libxmlPreviousState ) ; $ links = [ ] ; foreach ( $ this -> tags as $ tag => $ attribute ) { foreach ( $ dom -> getElementsByTagName ( $ tag ) as $ element ) { $ link = $ element -> getAttribute ( $ attribute ) ; if ( ! $ link ) { continue ; } $ links [ ] = clean_url ( url_to_absolute ( $ this -> url , $ link ) , true , true ) ; } } return $ this -> extractedLinks = array_unique ( $ links ) ; }
Extracs links from body
@return array
@uses $body
@uses $extractedLinks
@uses $tags
@uses $url
Extracs links from body