<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SamplePhpCodes.com &#187; Google trends php script</title>
	<atom:link href="http://www.samplephpcodes.com/tag/google-trends-php-script/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.samplephpcodes.com</link>
	<description>Get PHP Code Help, Sample PHP Scripts,PHP Script Demos</description>
	<lastBuildDate>Mon, 05 Apr 2010 15:39:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Google trends php script</title>
		<link>http://www.samplephpcodes.com/sample-php-codes/use-full-codes/google-trends-php-script/</link>
		<comments>http://www.samplephpcodes.com/sample-php-codes/use-full-codes/google-trends-php-script/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 06:04:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Useful Codes]]></category>
		<category><![CDATA[get a web content in php]]></category>
		<category><![CDATA[google search words in php]]></category>
		<category><![CDATA[Google trends php script]]></category>
		<category><![CDATA[Google Trends: PHP Frameworks.]]></category>
		<category><![CDATA[grab a website using php]]></category>
		<category><![CDATA[grab trends php]]></category>
		<category><![CDATA[latest search results from google using php]]></category>

		<guid isPermaLink="false">http://samplephpcodes.com/?p=102</guid>
		<description><![CDATA[This code is used for get the keywords from the Google HotTrens.U can use the grabtrends() to get the curerent trends words. it return an array of keywords.You can change the $url to get coountry specific keywords ex: $url = &#8220;http://www.google.co.in/trends/hottrends&#8221;; gives the INDIAN keywords. You just need to include the following code wereever you [...]]]></description>
			<content:encoded><![CDATA[<p>This code is used for get the keywords from the  Google HotTrens.U can use the grabtrends() to get  the curerent trends words. it return an array of keywords.You can change the $url to get coountry specific keywords  ex: $url = &#8220;http://www.google.co.in/trends/hottrends&#8221;;  gives the INDIAN keywords.<br />
You just need to include the following code wereever you want and call the function.</p>
<pre class="brush: php;">
&lt;?php
/*
 This code is used for get the keywords from the
 Google HotTrens.U can use the grabtrends() to get
 the curerent trends words. it return an array of keywords
 u can change the $url to get coountry specific keywords
 ex: $url = &quot;http://www.google.co.in/trends/hottrends&quot;;
 gives the INDIAN keywords

*/

//---- this function returns the keywords---
function grabtrends()
{
	$url = &quot;http://www.google.com/trends/hottrends&quot;;
	global $trendurl;
	$url=$trendurl;
	$arr = curlgrab($url);

	$pattern = '|&amp;sa=X&quot;&gt;(.*?)&lt;/a&gt;|';
	$matches = null;
	preg_match_all( $pattern, $arr['page'], $matches );

	return $matches[1]; // output is an array of key words
}

//---- functio to get data from a website--/
function curlgrab( $url, $ch = null ) {

	if( $ch != null ) {
	     curl_setopt( $ch, CURLOPT_URL, $url );
	}
	 else
	 {
	    $ch = curl_init( $url );
	    curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
	    curl_setopt( $ch, CURLOPT_COOKIEJAR, 'cookies.txt' );
	    curl_setopt( $ch, CURLOPT_USERAGENT, &quot;Mozilla/4.0 (compatible; MSIE 5.01;Windows NT 5.0)&quot; );
 	  }

$arr[ 'ch' ] = $ch;
$arr[ 'page' ] = curl_exec( $ch );
return $arr;
}
?&gt;
</pre>
<p>To test this code use this</p>
<pre class="brush: php;">
// include the above code 

$out=grabtrends();
echo '&lt;h2&gt;Google Trends Keywords&lt;/h2&gt;';

foreach($out as $keyword)
       echo &quot;&lt;h3&gt;&quot;.$keyword.&quot;&lt;/h3&gt;&quot;;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.samplephpcodes.com/sample-php-codes/use-full-codes/google-trends-php-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
