DotNetOpenAuth - is it possible to login (to google) entirely from code? -
i search answer last 2 days, can't seem find (definitive) answer. need csv data google trends, in order need login google account. far tried use following code (originally posted byt @user1883833 in oauth google trends download csv file :
static void main(string[] args) { using (var client = new webclient()) { var terms = new list<string>() {"debt", "profit", "euro", "dollar", "financial", "economy", "federal reserve", "earnings", "fed", "consumer spending" , "employment", "unemployment", "jobs" }; var username = "your username"; var password = "password"; var response = client.downloadstring(string.format("https://www.google.com/accounts/clientlogin?accounttype=google&email={0}&passwd={1}&service=trendspro&source=test-test-v1", username, password)); // sid first line in response // auth line var auth = response.split('\n')[2]; client.headers.add("authorization", "googlelogin " + auth); int = 1; while (terms.count > 0) { // google limits 5 sets of terms per request var arr = terms.take(5).toarray(); terms = terms.skip(5).tolist(); var joined = string.join("%2c%20", arr); byte[] csv = client.downloaddata(string.format("http://www.google.com/trends/trendsreport?hl=en-us&q={0}&cmpt=q&content=1&export=1", joined)); // todo: downloaded csv file: console.writeline(encoding.utf8.getstring(csv)); file.writeallbytes(string.format("report{0}.csv", i), csv); i++; } } }
while above works fine - allows few downloads before "you have reached quota limit. please try again later." message, google appear block ip looong time (24 hours or more - code, still can download data website on same login, limitation can bypassed proxy - again, few queries can processed before hitting limit).
as far can see - above login, doesn't generate cookies google use in google trends. know can login using dotnetopenauth, question is: can login using code only, without rediraction google login page? mean like:
string username="username"; string password="password"; dotnetopenauth.googlelogin(username,password);
is possible? if not - there other way login allow normal quota limit?
thanks in advance.
best regards.
Comments
Post a Comment