通过使用这种饲料按日期获取谷歌趋势的PHP
我们可以得到谷歌目前的趋势。
但我需要获得前一天的趋势。目前趋势中的搜索字词会经常变化,所以我试图在当天开始的时候获得前一天的趋势主题。
但我不知道的网址获得前一天的趋势?
任何机构都可以让我解决这个问题吗?谢谢。
通过使用这种饲料按日期获取谷歌趋势的PHP
我们可以得到谷歌目前的趋势。
但我需要获得前一天的趋势。目前趋势中的搜索字词会经常变化,所以我试图在当天开始的时候获得前一天的趋势主题。
但我不知道的网址获得前一天的趋势?
任何机构都可以让我解决这个问题吗?谢谢。
你可以从这里试试这个:http://www.fromzerotoseo.com/scraping-google-hot-trends/
<?php
// Scraping New Year’s Eve
$result = getPage(
'[proxy IP]:[port]',
'http://www.google.com/trends/hottrends?sa=X&date=2008-12-31',
'http://www.google.com/trends/hottrends?sa=X',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8',
1,
5);
if (empty($result['ERR'])) {
preg_match_all(
'(<td class=num>\d+\.</td>.*<td><a href="(.*)">(.*)</a></td>)siU',
$result['EXE'], $matches);
// some URL tuning here…
for ($i = 0; $i < count($matches[1]); $i++) {
$matches[1][$i] = 'http://www.google.com' . $matches[1][$i];
}
// Job's done!
// $matches[1] array contains all URLs, and
// $matches[2] array contains all anchors
} else {
// WTF? Captcha or network problems?
// ...
}
?>
接受的答案不再有效。搜索了很多后,我终于找到了一个工作PHP api to get google trends。
有了这一个你可以看看图,区域和相关查询从谷歌趋势的时间范围,是这样的:
$gs=new GSession($guser, $gpass);
$gs->authenticate();
$gt=new GTrends($gs, 'es');
$gt->addTerm('something1')->addTerm('something2')->setTime('2017-04-01 2017-04-19');
$gt->getGraph('csv'));
编辑:库是不是免费的了,它有28eur的费用。
你总是可以cron一个简单的脚本来刮n分钟,每隔几个小时,再加上一个计数器,每增加一个单词就可以看到 – 2011-03-19 11:59:47