Example of extracting data from a web table

Build a bot to open a browser window to the Wikipedia website, extract the data from a table, and write it to a CSV file on your desktop. This example uses actions from the Browser, Data Table, Recorder, and Window packages.

Procedure

To extract data from a table, do the following steps:

  1. Create a new bot:
    1. On the left panel, click Automation.
    2. Click Create new > Bot.
    3. In the Create Task Bot window, enter the bot name.
    4. Accept the default folder location: \Bots\
      To change the default bot storage location, click Choose and follow the prompts.
    5. Click Create and edit.

For information about bot naming conventions, see Create your first bot.

  1. Open a browser window to the web page from which you will extract the table.
    1. Double-click or drag the Browser > Open action.
    2. Select your preferred browser.
    3. In the Link to open field, enter https://en.wikipedia.org/wiki/Table_(information).
    4. Click Save.
    5. Click Run.
      The bot opens the window.
  2. Specify the table.
    1. Double-click or drag the Recorder > Capture action.
    2. From the far-right panel, in the Window options, select the Browser tab and then select the Table (information) - Wikipedia window from the drop-down list.
      If the window title does not appear in the list, click Refresh.
    3. Click Capture object.
      The Table (information) - Wikipedia window activates.
    4. Hover over the Age table below the Basic description heading.
      An orange box appears, surrounding the table.
    5. Click the table.
      The Object Processing message box appears.
    6. Return to the Control Room.
    7. In the Object properties table, verify the Control Type is TABLE.
      If it is not, click Recapture object.
    8. From the Action to take on object drop-down list, select Get table.
    9. In the Save the outcome to a variable field, create the Tabledata variable.
    The Table (information) - Wikipedia window is saved as the variable $Browser1$.
  3. Specify the file where to save the data.
    1. Double-click or drag the Data Table > Write to file action.
    2. From the Data table name list, select Tabledata.
    3. In the Enter file name field, select your file.
      For example, C:\Users\<username>\Desktop\WikipediaTable.csv.
    4. Select to overwrite the existing file.
  4. Close the Table (information) - Wikipedia window.
    1. Double-click or drag the Browser > Close action.
    2. Select the Variable tab and insert $Browser1$.
  5. Click Save.
  6. Click Run.
    The bot creates a CSV file on the desktop with data on seven indexes, their values, and net change.