I'm a bit of a data analysis geek, and a while back I wanted to crunch some numbers related to my Google search history. Unfortunately, I couldn't find a good way to export/process it in bulk. With some digging, though, I found out that there is a way to fetch searches from your history in XML format. Combining this with a PHP script (using cURL), I came up with a way to cycle through and process all my searches. Here's how you can do the same:
Step 1: Enable
Google Web History. If you're militant about privacy, this probably isn't for you. It will save your search history in your Google account (only applies when you're logged in during the search).
Step 2: Log in to your Google account and save your cookie file somewhere where you can use it for a cURL request. This needs to be saved in the Netscape standard cookies.txt format. If you have an early version of Firefox, your cookies may already in this format, so you just need to find the file. If you have a more recent version of Firefox, you will need to export your cookies to that format using an add-on like
Export Cookies 1.0. If you're using Internet Explorer, there is a built-in
Import/Export Wizard to export your cookies to the cookies.txt format. Chrome, Safari, etc., you'll have to investigate how your browser stores cookies and how to export them into cookies.txt format.
Step 3: Put the cookies.txt files and
this PHP script somewhere where you can execute the script:
Step 4: Execute the script!
Make sure that, if these files are in a public location (like a web-accessible server), that you delete them when you're done to prevent other people from using your login cookies or seeing your search history.
That's it! You can now analyze your own search history however you feel like it. Hopefully the script is fairly self-explanatory - you can use the different XML elements to do whatever you want. Note that you need to specify the location of the cookies.txt file in the script, and, if you want to save the searches to your own database, you also need to supply the database connection information. If you have any questions, feel free to email me.