Piwik\Plugins\SEO\Metric\Google::fetchIndexedPagesCount PHP Method

fetchIndexedPagesCount() public method

public fetchIndexedPagesCount ( $domain )
    public function fetchIndexedPagesCount($domain)
    {
        $url = self::SEARCH_URL . urlencode($domain);
        try {
            $response = str_replace(' ', ' ', Http::sendHttpRequest($url, $timeout = 10, @$_SERVER['HTTP_USER_AGENT']));
            if (preg_match('#([0-9,\\.]+) results#i', $response, $p)) {
                return NumberFormatter::getInstance()->formatNumber((int) str_replace(array(',', '.'), '', $p[1]));
            } else {
                return 0;
            }
        } catch (\Exception $e) {
            $this->logger->warning('Error while getting Google search SEO stats: {message}', array('message' => $e->getMessage()));
            return null;
        }
    }