i was able to get this code for c# which works perfectly fine..but due to dependancy issues i need the java/ python equivalent of it..
class Program
{
static void Main(string[] args)
{
var client = new WebClient();
String userName = "*******";
String password = "*******";
var response = client.DownloadString("https://www.google.com/accounts/ClientLogin?accountType=GOOGLE&Email="+userName+"@gmail.com&Passwd="+password+"&service=trendspro&source=test-test-v1");
var sid = response.Split('\n')[0];
client.Headers.Add("Cookie", sid);
String downloadURL = "http://www.google.com/insights/search/overviewReport?cat=0-7&geo=BR&date=today%207-d&cmpt=geo&content=1&export=1";
byte[] csv = client.DownloadData(downloadURL);
Console.WriteLine(Encoding.Unicode.GetString(csv));
Console.ReadLine();
}
}
Fetching a file
The
urllib2module is what you’re looking for here. A HOWTO is available as well. For authentication, you’re looking forHTTPBasicAuthHandler. See http://docs.python.org/library/urllib2.html#examples for an example.Handling CSV data
For handling CSV data, you’ll want to use the
csvmodule.Question is lacking effort
If the documentation provided here is not enough for you to fake your way through a solution, please update the question with the things you’ve tried and specific questions on what isn’t working for you.