为什么相同的谷歌搜索API在R与浏览器中产生不同的结果



在浏览器(Chrome(和R中对完全相同的Google Search API查询求和会返回不同数量的结果。这可能是什么原因呢?唯一明显的区别是,我从我的计算机(基于英国(在浏览器中提交查询,而R结果来自基于NL的GCE VM。即使我在查询字符串中指定了搜索国家/地区,这是否是原因?

# Pasted in the browser address bar
https://www.googleapis.com/customsearch/v1?q=%22KALLIGIANNIS%22%20Rethymno&num=10&lr=lang_en&cx=SSS&gl=gr&cr=countryGR&dateRestrict=date:r:20150831:20170831&key=XXX&alt=json
# Get request in R
httr::GET('https://www.googleapis.com/customsearch/v1?q=%22KALLIGIANNIS%22%20Rethymno&num=10&lr=lang_en&cx=SSS&gl=gr&cr=countryGR&dateRestrict=date:r:20150831:20170831&key=XXX&alt=json')

浏览器中的结果显示:

"searchInformation": {
"searchTime": 0.133114,
"formattedSearchTime": "0.13",
"totalResults": "109",
"formattedTotalResults": "109"

R 中的结果

oneresult <- GET('https://www.googleapis.com/customsearch/v1?q=%22KALLIGIANNIS%22%20Rethymno&num=10&lr=lang_en&cx=SSS&gl=gr&cr=countryGR&dateRestrict=date:r:20150831:20170831&key=XXX&alt=json')
content(oneresult)[[5]]
$searchTime
[1] 0.584238
$formattedSearchTime
[1] "0.58"
$totalResults
[1] "59"
$formattedTotalResults
[1] "59"

谷歌搜索算法是一个黑匣子。它根据地理位置和其他参数产生不同的结果,并非所有参数都是已知的。

例如,在常规模式下使用浏览器(而不是通过 googleapis(与隐身模式也可能产生不同的结果。

我的猜测是你的假设是正确的(差异是由搜索的来源引起的(。

最新更新