Tôi đã làm việc từ mã gốc được đăng tại Matlab login and download failure when calling WebClient.DownloadFile để thử và tải xuống dữ liệu xu hướng của google trong csv trực tiếp từ MATLAB.matlab tải xuống google trends csv
Tôi cũng đọc trong bài Emanuele tại login with curl and get session rằng chính sách xác thực của Google đã thay đổi, và bây giờ mã của tôi trông như thế này:
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)
mà lợi nhuận unforgivingly:
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>
Nếu ai có khả năng truy cập google xu hướng dữ liệu csv từ MATLAB, bạn là anh hùng của tôi