title: imacros firefox use csv file to enter keywords into search box and extract results
body: <p>I'm using the imacros free plugin for firefox to scrape data from a javascript search form on a website.  Here is a breakdown of my macro so far.</p>
  
  <p>This portion of the macro below automatically enters the keyword "superman" into the search form.</p>
  
  <pre><code>VERSION BUILD=8300326 RECORDER=FX
  TAB T=1
  URL GOTO=http://www.example.com/pricelist
  FRAME F=1
  TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Pricelistsearchform/ ATTR=ID:Keyphrase CONTENT=superman
  TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/Pricelistsearchform ATTR=NAME:SearchBarcode&amp;&amp;VALUE:Get&lt;SP&gt;Value
  </code></pre>
  
  <p>A list of results now loads and i use the following code to loop through each of the results and extract the results:</p>
  
  <pre><code>SET !LOOP 3
  TAG XPATH=id('SearchForm')/form/fieldset/table/tbody/tr[{{!LOOP}}]/td[1]/a
  TAG XPATH=id('Results')/table/tbody/tr[2]/td[2] EXTRACT=TXT
  TAG XPATH=id('Results')/table/tbody/tr[2]/td[4] EXTRACT=TXT
  BACK
  </code></pre>
  
  <p>I would like to amend the code to use a csv file to automatically enter names into the search field one at a time and then loop through and extract all the results as normal.  </p>
  
  <p>For example if i have a csv file that looks like this:  superman, superman 2, superman 3...etc
  I would like the macro to enter "superman" into the search form, loop through all the results  and extract them.  It should then enter "superman 2" and extracts all the results and so on...   </p>
  
  <p>I've experimented already without success in the example below using the !DATASOURCE command.  I'm not sure if i need to split my macro into two seperate ones as i have two loops in the example below, or whether this be achieved with javascript. </p>
  
  <pre><code>VERSION BUILD=8300326 RECORDER=FX
  TAB T=1
  SET !DATASOURCE titlelist.csv
  SET !DATASOURCE_LINE {{!LOOP}
  URL GOTO=http://www.example.com/pricelist
  FRAME F=1
  TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Pricelistsearchform/ ATTR=ID:Keyphrase CONTENT={{!COL1}}
  TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/Pricelistsearchform ATTR=NAME:SearchBarcode&amp;&amp;VALUE:Get&lt;SP&gt;Value 
  SET !LOOP 3 
  TAG XPATH=id('SearchForm')/form/fieldset/table/tbody/tr[{{!LOOP}}]/td[1]/a
  TAG XPATH=id('Results')/table/tbody/tr[2]/td[2] EXTRACT=TXT
  TAG XPATH=id('Results')/table/tbody/tr[2]/td[4] EXTRACT=TXT
  BACK
  </code></pre>
  
  <p>Many thanks for the help</p>