public function testSetHtml() { $html = '<html><body></body></html>'; $this->helperMakeAccessable($this->SUT, '_lastHtml', false); $this->assertFalse($this->SUT->getLastLoadedHtml()); $result = $this->helperMakeAccessable($this->SUT, '_setHtml', array($html)); $this->assertSame($html, $this->SUT->getLastLoadedHtml()); }
public function getAlexa() { try { $seostats = new SEOstats(); if ($seostats->setUrl($this->url)) { return Alexa::getGlobalRank(); } } catch (Exception $e) { $e->getMessage(); } }
/** * Returns the Sistrix visibility index * * @access public * @param url string The URL to check. * @return integer Returns the Sistrix visibility index. * @link http://www.sistrix.com/blog/870-sistrix-visibilityindex.html */ public static function getVisibilityIndex($url = false) { $url = parent::getUrl($url); $domain = Helper\Url::parseHost($url); $dataUrl = sprintf(Config\Services::SISTRIX_VI_URL, urlencode($domain)); $html = parent::_getPage($dataUrl); @preg_match_all('#<h3>(.*?)<\\/h3>#si', $html, $matches); return isset($matches[1][0]) ? $matches[1][0] : parent::noDataDefaultValue(); }
/** * Return Link metrics from the (free) Mozscape (f.k.a. Seomoz) API. * * @access public * @param cols string The bit flags you want returned. * @param url string The URL to get metrics for. */ public static function getCols($cols, $url = false) { if ('' == Config\ApiKeys::MOZSCAPE_ACCESS_ID || '' == Config\ApiKeys::MOZSCAPE_SECRET_KEY) { throw new E('In order to use the Mozscape API, you must obtain and set an API key first (see SEOstats\\Config\\ApiKeys.php).'); exit(0); } $expires = time() + 300; $apiEndpoint = sprintf(Config\Services::MOZSCAPE_API_URL, urlencode(Helper\Url::parseHost(parent::getUrl($url))), $cols, Config\ApiKeys::MOZSCAPE_ACCESS_ID, $expires, urlencode(self::_getUrlSafeSignature($expires))); $ret = parent::_getPage($apiEndpoint); return !$ret || empty($ret) || '{}' == (string) $ret ? parent::noDataDefaultValue() : Helper\Json::decode($ret, true); }
public static function getPageMetrics($url = false) { $url = parent::getUrl($url); $dataUrl = sprintf(Config\Services::OPENSITEEXPLORER_URL, 'links', '1', $url); $html = parent::_getPage($dataUrl); $doc = parent::_getDOMDocument($html); $data = @$doc->getElementsByTagName('td'); if ($data->item(0)) { return array('domainAuthority' => trim(strip_tags($data->item(0)->textContent)), 'pageAuthority' => trim(strip_tags($data->item(1)->textContent)), 'linkingRootDomains' => trim(strip_tags($data->item(2)->textContent)), 'totalInboundLinks' => trim(strip_tags($data->item(3)->textContent))); } else { return parent::noDataDefaultValue(); } }
public static function getPageMetrics($url = false) { $url = parent::getUrl($url); $dataUrl = sprintf(Config\Services::OPENSITEEXPLORER_URL, 'links', '1', urlencode($url)); $html = static::_getPage($dataUrl); $doc = parent::_getDOMDocument($html); $xpath = parent::_getDOMXPath(@$doc); $tooltipNodes = @$xpath->query('//*[@class="tooltip"]'); $resultNodes = @$xpath->query('//*[@class="has-tooltip"]'); $resultNodes2 = @$xpath->query('//*[@class="has-tooltip"]/span[1]'); $unitNodes = @$xpath->query('//*[@class="has-tooltip"]/span[2]'); if (0 < $resultNodes->length) { return (object) array('domainAuthority' => (object) array('result' => intval($resultNodes2->item(0)->nodeValue), 'unit' => trim(strip_tags($unitNodes->item(0)->nodeValue)), 'descr' => trim(strip_tags($tooltipNodes->item(0)->nodeValue))), 'pageAuthority' => (object) array('result' => intval($resultNodes2->item(1)->nodeValue), 'unit' => trim(strip_tags($unitNodes->item(1)->nodeValue)), 'descr' => trim(strip_tags($tooltipNodes->item(1)->nodeValue))), 'justDiscovered' => (object) array('result' => intval(str_replace(',', '', strip_tags($resultNodes->item(2)->nodeValue))), 'unit' => trim(strip_tags($resultNodes2->item(2)->nodeValue)), 'descr' => trim(strip_tags($tooltipNodes->item(2)->nodeValue))), 'linkingRootDomains' => (object) array('result' => intval(str_replace(',', '', $resultNodes->item(3)->nodeValue)), 'unit' => trim(strip_tags($resultNodes2->item(3)->nodeValue)), 'descr' => trim(strip_tags($tooltipNodes->item(3)->nodeValue))), 'totalLinks' => (object) array('result' => intval(str_replace(',', '', $resultNodes->item(4)->nodeValue)), 'unit' => trim(strip_tags($resultNodes2->item(4)->nodeValue)), 'descr' => trim(strip_tags($tooltipNodes->item(4)->nodeValue)))); } else { return parent::noDataDefaultValue(); } }
public static function getPagespeedScore($url = false, $strategy = 'desktop') { $url = parent::getUrl($url); $ret = self::getPagespeedAnalysis($url, $strategy); // Check if $ret->score exists for backwards compatibility with v1. if (!isset($ret->score)) { return !isset($ret->ruleGroups->SPEED->score) || !$ret->ruleGroups->SPEED->score ? parent::noDataDefaultValue() : intval($ret->ruleGroups->SPEED->score); } else { return $ret->score; } }
private static function _getAlexaPage($url) { $domain = Helper\Url::parseHost($url); $dataUrl = sprintf(Config\Services::ALEXA_SITEINFO_URL, $domain); $html = parent::_getPage($dataUrl); return $html; }
/** * Returns the total count of URL shares via VKontakte * * @access public * @param url string The URL to check. * @return integer Returns the total count of URL shares. */ public static function getVKontakteShares($url = false) { $url = parent::getUrl($url); $dataUrl = sprintf(Config\Services::VKONTAKTE_INFO_URL, urlencode($url)); $htmlData = parent::_getPage($dataUrl); @preg_match_all('#^VK\\.Share\\.count\\(1, (\\d+)\\);$#si', $htmlData, $matches); return isset($matches[1][0]) ? intval($matches[1][0]) : parent::noDataDefaultValue(); }
protected static function getDomainFromUrl($url) { $url = parent::getUrl($url); $domain = Helper\Url::parseHost($url); static::guardDomainIsValid($domain); return $domain; }
/** * Returns an array of interaction counts (shares, comments, clicks, reach) for host of $url on Xing. * * @access public * @param url string The URL to check. * @return array Returns URL shares, comments, clicks and 'reach'. * @link https://blog.xing.com/2012/01/xing-share-button/ Return values explained (German) */ public static function getXingShares($url = false) { $host = parent::getHost($url); $dataUrl = sprintf(Config\Services::XING_SHAREBUTTON_URL, urlencode($host)); $htmlData = parent::_getPage($dataUrl); @preg_match_all('/\\r?\\n(\\d+)\\r?\\n/s', $htmlData, $matches); if (isset($matches[1]) && 4 == sizeof($matches[1])) { return array('shares' => intval($matches[1][0]), 'comments' => intval($matches[1][1]), 'clicks' => intval($matches[1][2]), 'reach' => intval($matches[1][3])); } return parent::noDataDefaultValue(); }
private static function getWidgetUrl($url, $db, $reportType) { $url = parent::getUrl($url); $domain = Helper\Url::parseHost($url); $database = self::checkDatabase($db); if (false === $domain) { self::exc('Invalid domain name.'); } else { if (false === $database) { self::exc('db'); } else { $widgetUrl = Config\Services::SEMRUSH_WIDGET_URL; return sprintf($widgetUrl, $reportType, $database, $domain); } } }
/** * * @return mixed nodeValue */ protected static function parseDomByXpathsToIntegerWithoutTags($xpathDom, $xpathQueryList) { $nodeValue = static::parseDomByXpathsGetValue($xpathDom, $xpathQueryList); if ($nodeValue === null) { return parent::noDataDefaultValue(); } return self::retInt(strip_tags($nodeValue)); }
public static function getPagespeedScore($url = false) { $url = parent::getUrl($url); $ret = self::getPagespeedAnalysis($url); return !$ret->score ? parent::noDataDefaultValue() : intval($ret->score); }