Exemplo n.º 1
0
 function run()
 {
     $result = multiRequest($this->urls);
     $i = 0;
     foreach ($result as $page) {
         $dom = new DOMDocument();
         // creates new DOMdocument object
         @$dom->loadHTML($page);
         // parses html and loads it into the DOMdocument
         $metas = $dom->getElementsByTagName('meta');
         // gets all meta tags
         $this->live_pages[$i]['url'] = $this->urls[$i];
         // sets url
         $this->live_pages[$i]['title'] = get_the_first($dom->getElementsByTagName('title'));
         // gets the title
         $this->live_pages[$i]['description'] = $this->get_the_description($metas);
         // sets description
         $this->live_pages[$i]['h1'] = get_the_first($dom->getElementsByTagName('h1'));
         // gets h1
         $this->live_pages[$i]['other_h1s'] = array();
         $other_h1s = $dom->getElementsByTagName('h1');
         for ($count = 1; $count < $other_h1s->length; $count++) {
             array_push($this->live_pages[$i]['other_h1s'], htmlspecialchars($other_h1s->item($count)->textContent));
         }
         $i += 1;
     }
 }
Exemplo n.º 2
0
function do_stuff($stuff_to_work_on, $urls, $counter)
{
    $dom = new DOMDocument();
    // creates new DOMdocument object
    @$dom->loadHTML($stuff_to_work_on);
    // parses html and loads it into the DOMdocument
    $title = get_the_first($dom->getElementsByTagName('title'));
    // gets the title
    $metas = $dom->getElementsByTagName('meta');
    // gets all meta tags
    $h1 = get_the_first($dom->getElementsByTagName('h1'));
    // gets h1
    output_meta($urls[$counter], $title, $metas, $h1);
}