Using iMacros to save google results

Introduction

A follow up to my previous SEO article this will show how browser plugins / add-ons / extensions can be used to speed up the pure tedium of checking results in Google. I looked into these solutions after developing a .Net web application based on Google’s Custom Search API. This app has full reporting and graphical interfaces and centralised relational storage and multiple site management and some other bits and bobs hacked on! But, I wondered, there must be a simpler way for people who don’t know there way around Visual Studio to also test results from Google.

My previous article explained how to use a Firefox add-on called Grab Them All to automatically grab a shot of some Google results with very little set up time. This article is on iMacros and is a little more advanced, but still very easy to pick up! The big advantage of iMacros is just how powerful and flexible it is, and also we can save results as CSV files. These CSVs are not only smaller on disk but also much easier to use in practical ways.

What is iMacros?

iMacros is a suite of tools developed by Iopus. Some of the tools in the suite are very powerful and expensive but I’ll be showing you how to use the free browser plugins. Even though simpler, these are still powerful tools when use correctly. iMacros can be used to automate lots of different tasks that a user normal does, here we’ll use a simple macro to query some search terms in Google and return the results.

Installing iMacros

iMacros is an extension for Chrome, Internet Explorer and Firefox. For my dev work I like Firefox (I use Chrome for general browsing) so I’ll show you how to install it in FF4.

  1. Go to https://addons.mozilla.org/en-us/firefox/addon/imacros-for-firefox/
  2. Click “Add to Firefox”
  3. When the popup comes up click install.
  4. Restart Firefox
  5. All Set!

So what will this macro do?

This macro will be a nice simple demonstration, but may save any SEO practitioner a lot of time!

  1. It will read a list of URLs from a CSV file.
  2. It will loop through all of the URLs in the list.
  3. It will open each webpage in the browser.
  4. It will find a certain element in the page and copy the contents.
  5. These contents and the URL of the page will be saved to an output CSV file.

Coding the Macro

  1. First navigate to your macros folder for iMacros (default = My Documents \iMacros\Macros).
  2. Create a new text file and save it with an extension of .iim
  3. Open this file in any text editor, I use Notepad++.
  4. In this file use the below to construct the macro in this file.
VERSION BUILD=6000328
TAB T=1
'This will identify the version of iMacros you want to use
'(may be different for you) and get Firefox to open a new tab.


SET !EXTRACT_TEST_POPUP NO
'This stops the results from appearing in the browser, 
'we will be saving the results to look at later, not 
'monitor them in real time.


SET !DATASOURCE sites.csv
'Tell iMacros which file we want to read from. 
'This uses the sites CSV file from the default 
'data sources directory (default = My Documents\iMacros\Datasources)


SET !DATASOURCE_COLUMNS 1
'This is very important! You must tell iMacros how many fields are in each CSV row.


SET !LOOP 1
'This sets the default start index in the loop, and yes it starts at 1, 
'remind you of your VB6 days or is it just me?


SET !DATASOURCE_LINE {{!LOOP}}
'For each line in the file keep looping, well, for as many times 
'as you define in your repeat macro setting actually. More on that later.


URL GOTO={{!COL1}}  
'Get the value from the first column of the current row. This is the URL.


TAG POS=1 TYPE=DIV ATTR=ID:ires&&TXT:* EXTRACT=TXT      
'This line grabs the text from the first div element with the ID “ires”.
'Ires is the ID given to the element in Google where all the search 
'results are rendered to. If there are no results in the search then 
'iMacros will return an error, which is actually good because it makes 
'the results very easy to parse!


ADD !EXTRACT {{!URLCURRENT}}
'This appends the URL of the currently tested page to the 
'line in the CSV file, also for easy reference.


SAVEAS TYPE=EXTRACT FOLDER=* FILE=+{{!NOW:ddmmyyyy}}.csv
'This saves the extracted data to a CSV file. I’m calling the file name 
'the current date. This is nice when you start running the macro regularly!


WAIT SECONDS=1
'By adding a short wait it allows you to pause it a bit easier if needed.

Running The Macro

Now you have a macro in the correct folder, all you need to do is run the macro. Open up the add-on in your browser and select the macro you made from the list. Unfortunately you do have to manually set the amount of times you want the program to loop, but once you have just click Play Loop (NOT Play). The browser will play the loops instructions, saving the scraped data to CSV as it goes. When the loop has finished, you can then browse through the results or use them as input to another program.

Summing Up

Even this, the most basic version of iMacros, is very useful and flexible. I have shown just one interesting way to use it, but there are many more possibilities. You may want to look through the documentation for some more useful language features, but even this short bit of code can be used as a basis for larger scripts.

Also remember iMacros can be used to automate tasks in your standard web browsing.

Comments

comments powered by Disqus