télécharger csv de google insight pour la recherche

Vous avez besoin d’aide pour écrire un script qui télécharge des données à partir de Google Insight en c #

c’est l’URL de téléchargement et nécessite un identifiant

http://www.google.com/insights/search/overviewReport?q=test&cmpt=q&content=1&export=2

Comment puis-je entrer mon nom d’utilisateur et mot de passe? besoin d’aide im new to c #

Pour que cela fonctionne, vous devez d’abord vous authentifier afin d’obtenir un SID valide pour un site Google donné, qui puisse être utilisé pour accéder aux données. Voici comment vous pouvez y parvenir:

 class Program { static void Main(ssortingng[] args) { using (var client = new WebClient()) { // TODO: put your real email and password in the request ssortingng var response = client.DownloadSsortingng("https://www.google.com/accounts/ClientLogin?accountType=GOOGLE&[email protected]&Passwd=secret&service=trendspro&source=test-test-v1"); // The SID is the first line in the response var sid = response.Split('\n')[0]; client.Headers.Add("Cookie", sid); byte[] csv = client.DownloadData("http://www.google.com/insights/search/overviewReport?q=test&cmpt=q&content=1&export=2"); // TODO: do something with the downloaded csv file: Console.WriteLine(Encoding.UTF8.GetSsortingng(csv)); File.WriteAllBytes("report.csv", csv); } } } 

Ok, ça a changé depuis quelques jours.

Maintenant, vous devez passer auth et non SID.

Donc, le code est maintenant:

 class Program { static void Main(ssortingng[] args) { using (var client = new WebClient()) { // TODO: put your real email and password in the request ssortingng var response = client.DownloadSsortingng("https://www.google.com/accounts/ClientLogin?accountType=GOOGLE&[email protected]&Passwd=secret&service=trendspro&source=test-test-v1"); // The Auth line var auth = response.Split('\n')[2]; client.Headers.Add("Authorization", "GoogleLogin " + auth); byte[] csv = client.DownloadData("http://www.google.com/insights/search/overviewReport?q=test&cmpt=q&content=1&export=2"); // TODO: do something with the downloaded csv file: Console.WriteLine(Encoding.UTF8.GetSsortingng(csv)); File.WriteAllBytes("report.csv", csv); } } } 

Et maintenant, ça marche encore pour moi.