javascript-当有人点击搜索结果链接时,Google如何设置HTTP Referrer?

当有人点击搜索结果链接时,Google会设置HTTP Referrer.此引荐来源网址与URL地址栏中显示的地址不同(例如,它包含GET参数cd,该CD指示点击的链接的搜索结果位置).

看来这是用javascript完成的.我想在我的网站上做类似的事情,所以我想知道如何使用JavaScript精确地完成这种“引荐来源操纵”.

有任何想法吗?

解决方法:

当您点击其结果链接时,Google会通过自己的点击代理重定向您-代理的地址就是您在引荐来源网址中看到的地址.

示例:我去了http://www.google.cz,并搜索了“当有人单击搜索结果链接时Google如何设置HTTP Referrer?”.这导致了此请求:

GET http://www.google.cz/search?hl=cs&source=hp&biw=1276&bih=866&q=How+does+Google+set+the+HTTP+Referrer+when+someone+clicks+on+a+search+result+link%3F&aq=f&aqi=&aql=&oq=&gs_rfai=&fp=b29a84a7dd59af16 HTTP/1.1
Referer: http://www.google.cz/

从那里,我单击了第一个结果链接:How does Google set the HTTP Referrer when someone clicks on a search result link?
该点击是由JS事件捕获的,并被重新路由到此重定向器:

GET http://www.google.cz/url?sa=t&source=web&cd=1&ved=0CBoQFjAA&url=http%3A%2F%2F*.com%2Fquestions%2F4402502%2Fhow-does-google-set-the-http-referrer-when-someone-clicks-on-a-search-result-link&rct=j&q=How%20does%20Google%20set%20the%20HTTP%20Referrer%20when%20someone%20clicks%20on%20a%20search%20result%20link%3F&ei=WTgBTeOXLsHB8QPO44ybCA&usg=AFQjCNE22KabWH5TnkK1sRLGmqWQ4EvwxQ HTTP/1.1
Referer: http://www.google.cz/search?hl=cs&source=hp&biw=1276&bih=866&q=How+does+Google+set+the+HTTP+Referrer+when+someone+clicks+on+a+search+result+link%3F&aq=f&aqi=&aql=&oq=&gs_rfai=&fp=b29a84a7dd59af16

包含以下重定向代码段:

<body><a href="https://*.com/questions/4402502/how-does-google-set-the-http-referrer-when-someone-clicks-on-a-search-result-link" id=link target=_parent></body><script>var a=parent,b=parent.google,c=location;if(a!=window&&b){if(b.r){b.r=0;document.getElementById("link").click();}}else{document.getElementById("link").click();};</script><noscript><META http-equiv="refresh" content="0;URL='https://*.com/questions/4402502/how-does-google-set-the-http-referrer-when-someone-clicks-on-a-search-result-link'"></noscript>

最终将我发送到真实网址:

GET https://*.com/questions/4402502/how-does-google-set-the-http-referrer-when-someone-clicks-on-a-search-result-link HTTP/1.1
Referer: http://www.google.cz/url?sa=t&source=web&cd=1&ved=0CBoQFjAA&url=http%3A%2F%2F*.com%2Fquestions%2F4402502%2Fhow-does-google-set-the-http-referrer-when-someone-clicks-on-a-search-result-link&rct=j&q=How%20does%20Google%20set%20the%20HTTP%20Referrer%20when%20someone%20clicks%20on%20a%20search%20result%20link%3F&ei=WTgBTeOXLsHB8QPO44ybCA&usg=AFQjCNE22KabWH5TnkK1sRLGmqWQ4EvwxQ

因此,您是对的-尽管其中也涉及一些服务器端代码,但是大多数繁重的工作都是通过JavaScript完成的.

上一篇:Laravel 查询时无数据


下一篇:php-将Facebook检测为引荐来源?