Recent Google Searches

Someone was trying to hack my Recent Google Searches Widget to work outside of WordPress. This could be used as an include in any web page and when users arrive via google, bing, or yahoo they would see a search that would let them search the site using the same keywords.  Since the search engines only give you one link to the best match, this code will give you the rest of the matches.

I figured out what the person was doing wrong and I generalized the code to work pretty much anywhere that has php.

You can download the php file and the file I used to test it. rgs.zip

You need to include it using a server side include or in php you would enter:

include(“rgs.php”);

The history file winds up in a file called history.txt in the form of a serialized array. If you get more than a few hundred hits per minute you might want to use a database to store the data.

3 Responses to “Recent Google Searches”

  1. Keith says:

    I wrote a plugin that reads the Google Alert RSS and posts all of the search items as separate posts. It is not quite ready for prime time, but I will release it pretty soon.

    Keith

  2. Mark says:

    Is there a way to grab kewyord specific news articles from Google, Bing, etc. and post them to a blog?

    Similar to the Google Searches widget.

    Thanks

  3. Akash says:

    Thanks for everything again Keith! 🙂

Leave a Reply