0

How download with php google trends/insign cvs file?

reproduce:

  1. go to : http://www.google.com/trends?q=london%2C+paris&ctab=0&geo=all&date=all&sort=0

  2. in this page exist option to download cvs file that have all query result data by click. I need to that by php.

Thanks,

Yosef

Ben
  • 25,389
  • 34
  • 109
  • 165
  • 1
    use file_get_contents(http://www.google.com/trends/viz?q=london,+paris&date=all&geo=all&graph=all_csv&sort=0&sa=N) – Haim Evgi Jun 14 '11 at 11:13

2 Answers2

2
$query   = 'london, paris';
$csvFile = 'http://www.google.com/trends/viz?q='.urlencode($query).'&date=all&geo=all&graph=all_csv&sort=0&sa=N';

file_put_contents(file_get_contents($link), 
                  str_replace(array(',', ' ') '-', $query).'.cvs');
powtac
  • 40,542
  • 28
  • 115
  • 170
2

look on the file_get_contents function

<?php
$csv = file_get_contents('http://www.google.com/trends/viz?q=london,+paris&date=all&geo=all&graph=all_csv&sort=0&sa=N');    
echo $csv;
?>
Haim Evgi
  • 123,187
  • 45
  • 217
  • 223
  • Not working: I get: "You must be signed in to export data from Google Trends" – Ben Jun 14 '11 at 12:35
  • 1
    ok, i see this answer : http://stackoverflow.com/questions/6101151/get-google-trends-insights-with-php-login-auth-google – Haim Evgi Jun 14 '11 at 12:44