n3r0x Posted September 23, 2010 Share Posted September 23, 2010 I manage to get the SID= LSID= and Auth= using $url[0] = "https://www.google.com/accounts/ClientLogin"; $url[1] = "http://www.google.com/trends/viz?q=".$keyword."&date=all&geo=all&graph=all_csv&sort=0&sa=N"; $header = array('Connection: keep-alive', 'Keep-Alive: 115', 'Accept: ', 'Accept-Charset: utf-8', 'Accept-Encoding: ', 'Accept-Language: en-us,en', 'Referer: ', 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10' ); $login = "Email={myemail}&Passwd={mypassword}&accountType=GOOGLE&source=CompanyTool-cURL-0.1&service=trends"; // Login $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url[0]); curl_setopt($ch,CURLOPT_HEADER,true); curl_setopt($ch,CURLOPT_POSTFIELDS,$login); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_AUTOREFERER,true); curl_setopt($ch,CURLOPT_HTTPHEADER,$header); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $text = curl_exec($ch); print($text); curl_close($ch); but when i try to access $url[1] using: // Auth string i got from previous connction $auth = "XXXXXXXXXXXXXXXXXXXX"; // Add auth to header $header = array('Authorization: GoogleLogin auth='.$auth.''); // Start new curl session $ch = curl_init(); // Set URL curl_setopt($ch,CURLOPT_URL,$url[1]); curl_setopt($ch,CURLOPT_HTTPHEADER,$header); // So that we get the output curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); // Auto referer (not needed but added anyway "jic") curl_setopt($ch,CURLOPT_AUTOREFERER,true); curl_setopt($ch,CURLOPT_HEADER,true); curl_setopt($ch,CURLOPT_FOLLOWLOCATION,false); $text = curl_exec($ch); curl_close($ch); print($text); it says something like: "You must login to download data from google trends" Anyone know what´s wrong or have another way to download csv files from Google trends? Quote Link to comment Share on other sites More sharing options...
n3r0x Posted September 24, 2010 Author Share Posted September 24, 2010 Solved it.. Quote Link to comment Share on other sites More sharing options...
ramascaro Posted May 27, 2011 Share Posted May 27, 2011 n3r0x, could you tell us how did you solved it? Could this work with google insights too? Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.