matlab下载谷歌趋势csv

时间:2013-06-06 19:32:34

标签: .net matlab

我一直在使用Matlab login and download failure when calling WebClient.DownloadFile发布的原始代码,尝试直接从matlab下载csv中的谷歌趋势数据。

我还在Emanuele的帖子login with curl and get session上看到Google的身份验证政策已经更改,现在我的代码如下:

NET.addAssembly('System.Net'); 

url = strcat(['https://www.google.com/accounts/ClientLogin?accountType=GOOGLE&Email='     USERNAME '&Passwd=' PASSWORD '&service=trendspro&source=test-test-v1']); 

durl = System.String(strcat('http://www.google.com/trends/viz?q=', keyWord, '&date=all&geo=all&graph=all_csv&sort=0&scale=1&sa=N'))

if exist('googleWebClient','var') 
    client = googleWebClient; 
else 
    client = System.Net.WebClient; 

    response = client.DownloadString(url); 
    sid = char(response.ToString); 
    sid = regexp(sid, '\n', 'split'); 

    client.Headers.Add('Cookies', char(sid(1))); 

    client.Headers.Add('Authorization', strcat(   'GoogleLogin '  ,  char(sid(3))   )   ); 


end 


client.DownloadString(durl)

无情地回归:

ans = 

<div id="report">
    <div class="timeBandTitle">An error has been detected</div>
    <div class="timeBandSubTitle">You have reached your quota limit. Please try again later.</div>
  </div>

如果有人能够从matlab访问谷歌趋势csv数据,那么你就是我的英雄

1 个答案:

答案 0 :(得分:0)

假设您实际上没有达到配额限制,我怀疑您没有turned on API access。 (解释为0的配额限制?!)

可以在服务中找到。