public static function getCompetitors($url = false, $db = false) { $db = false !== $db ? $db : Config\DefaultSettings::SEMRUSH_DB; $dataUrl = self::getWidgetUrl($url, $db, 'organic_organic'); $data = self::getApiData($dataUrl); return !is_array($data) ? parent::noDataDefaultValue() : $data['organic_organic']; }
/** * 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 getApiCredits() { self::guardApiKey(); $dataUrl = sprintf(Config\Services::SISTRIX_API_CREDITS_URL, Config\ApiKeys::SISTRIX_API_ACCESS_KEY); $json = static::_getPage($dataUrl); if (empty($json)) { return parent::noDataDefaultValue(); } $json_decoded = Helper\Json::decode($json, true); if (!isset($json_decoded['answer'][0]['credits'][0]['value'])) { return parent::noDataDefaultValue(); } return $json_decoded['answer'][0]['credits'][0]['value']; }
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; } }
public static function getPageLoadTime($url = false) { $xpath = self::_getXPath($url); $nodes = @$xpath->query("//*[@id='section-load']/div/section/p"); return !$nodes->item(0) ? parent::noDataDefaultValue() : strip_tags($nodes->item(0)->nodeValue); }
/** * 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(); }
/** * 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(); }
/** * * @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); }
protected static function getWidgetData($url, $db, $reportType, $valueKey) { $db = false !== $db ? $db : Config\DefaultSettings::SEMRUSH_DB; $dataUrl = self::getWidgetUrl($url, $db, $reportType); $data = self::getApiData($dataUrl); return !is_array($data) ? parent::noDataDefaultValue() : $data[$valueKey]; }