/** * These are the SEOmoz just discovered data * @return multitype: */ public function getMozJustDiscovered() { $html = $this->moz->getData(MozServices::JD, $this->url); file_put_contents('just-discovered.txt', $html); $parser = new HtmlParser($html, $this->url); $tables = $parser->getTags('table'); $results = array(); if (count($tables) > 0) { $table = null; foreach ($tables as $tbl) { if (isset($tbl->attributes['id']) && $tbl->attributes['id'] === 'results') { $table = $tbl; break; } } //moz has data if (!empty($table)) { $p2 = new HtmlParser($table->raw, $this->url); $rows = $p2->getTags('tr'); foreach ($rows as $tr) { $p3 = new HtmlParser($tr->raw, $this->url); $tds = $p3->getTags('td'); if (!empty($tds[0]->text)) { array_push($results, array('link' => trim(strip_tags($tds[0]->text)), 'text' => trim(strip_tags($tds[1]->text)), 'pageAuthority' => trim(strip_tags($tds[2]->text)), 'DomainAuthority' => trim(strip_tags($tds[3]->text)), 'DiscoveryTime' => preg_replace('/\\s+/', ' ', trim(strip_tags($tds[4]->text))))); } } //no moz data } else { array_push($results, array('link' => 'No Data', 'text' => 'No Data', 'pageAuthority' => 'No Data', 'DomainAuthority' => 'No Data', 'DiscoveryTime' => 'No Data')); } } return $results; }
$finish = microtime(true); $total_time = round($finish - $start, 4); $resp->url = $_GET['arg0']; $resp->start = $start; $resp->finish = $finish; $resp->totalSeconds = $total_time; //no follow? $obeyNoFollow = true; if (isset($_GET['arg1']) && $_GET['arg1'] == 'false') { $obeyNoFollow = false; } //host $host = Utils::getBaseHost($_GET['arg0']); //parse the page $parser = new HtmlParser($result, $_GET['arg0']); $links = $parser->getTags('a'); $resp->links = array(); foreach ($links as $node) { if (!empty($node->attributes['href']) && !(isset($node->attributes['rel']) && strtolower($node->attributes['rel']) === 'nofollow' && $obeyNoFollow)) { $link = $node->attributes['href']; //validate hosts $lHost = Utils::getBaseHost($link); if (empty($lHost)) { $lHost = $host; } if ($lHost !== $host) { break; } $normal = Utils::normalizePath($link, $_GET['arg0']); if (!in_array($normal, $resp->links)) { array_push($resp->links, $normal);