如何从Google获取引荐来源搜索查询? [英] How to get the referer search query from google?

查看:377
本文介绍了如何从Google获取引荐来源搜索查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近两天前,以下代码可用于从google获取搜索查询:

As recently as two days ago, the following code worked to get the search query from google:

$refer = parse_url($_SERVER['HTTP_REFERER']);
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
$query = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY);

if(strstr($host,'www.google.com'))
{
    //do google stuff
    $qstart = strpos($query, 'q=') +2;
    $qend = strpos($query, '&', $qstart);
    $qlength = $qend - $qstart;
    $querystring = substr($query, $qstart, $qlength);
    $querystring = str_replace('q=','',$querystring);
    $keywords = explode('%20',$querystring);
    $keywords = implode(' ', $keywords);
    return $keywords;                      
    }

但是,现在没有.我通过使用echo($ query)测试了它,看来Google处理引荐来源查询请求的方式已经改变.以前包含$ query

However, now it does not. I tested it by using echo($query) and it appears that the way google processes referrer query requests has changed. Previously $query included

"q=term1%20term2%20term3%20...

但是,现在,当回显$ query时,我得到以下输出:

Now, however, I am getting the following output when $query is echo'ed:

sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CCsQFjAB&url=http%3A%2F%2Fexample.com%2F&ei=vDA-UNnxHuOjyAHlloGYCA&usg=AFQjCNEvzNXHULR0OvoPMPSWxIlB9-fmpg&sig2=iPinsBaCFuhCLGFf0JHAsQ

有没有办法解决这个问题?

Is there a way to get around this?

推荐答案

很抱歉,但这是Google的全球政治变革.

Sorry to say, but it's global Google politics change.

查看网络链接

http://googlewebmastercentral.blogspot.ru/2012/03/upcoming-changes-in-googles-http.html

这意味着用户是否登录Google帐户. 您可以自己尝试:如果您的Google搜索网址以https://开头,则表示Google会出于隐私目的而隐藏一些临时参数.

This means if user sign in Google account. You can try it yourself: if your Google search url starts with https:// this means Google will hide some scratch parameters for the sake of privacy.

这篇关于如何从Google获取引荐来源搜索查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆