How to get data from google trends by country

Authors: CodeToday | Google Trends | Views: 1699 | Posted: 08 AM: 09/09/2017

How to get data from google trends by countryGoogle search gives the user a very useful tool that is google trends. This tool allows users to know at the present time which keywords are most searched real-world people, based on which the user can make appropriate advertising methods.

In this tutorial I will show how to get data from google trends by country specific, there is a list of countries with filtered paths.

 See Also: How to compare keywords with google trends

Knowledge needed to know in this article

  1. curl_init(): Get data from[...]
  2. Xml regular expression: Analysis of data structure according to xml

List of url countries according to google trends Argentina Australia Austria Belgium Brazil Canada Chile Colombia Czech Republic Egypt Finland France Germany Greece Hong Kong Hungary India Indonesia Israel Italy Japan Kenya Malaysia Mexico Netherlands New Zealand Nigeria Norway Philippines Poland Romania Russia Saudi Arabia Singapore South Africa South Korea Spain Sweden Switzerland Taiwan Thailand Turkey Ukraine United Kingdom United States Vietnam

Full PHP Source Code

Here I will take the example with usa

$url = '';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPGET, 1 );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION , 1 );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION , 1 );
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_REFERER, $ref );
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);     
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
$result = curl_exec($ch);
echo '<ul>';
$trends = new SimpleXmlElement($result);
foreach($trends->channel->item as $value) { 
       $textTitle   = $value->title;
	   echo '<li>'.$textTitle.'</li>';       
echo '</ul>';

Note: Google Trends does not limit the number of queries, so you can get unlimited

If you have any questions, please leave a message below