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
-
Open a new bot:
- On the left panel, click Automation.
-
Click Create new > Bot.
- In the Create Task Bot window, enter a bot name.
-
Accept the default folder location \Bots\.
To change where your bot is stored, click Choose and follow the prompts.
- Click Create and edit.
-
Open a browser window to the web page from which you will extract the
table.
- Double-click or drag the Browser > Open action.
- Select your preferred browser.
- In the Link to open field, enter https://en.wikipedia.org/wiki/Table_(information).
- Click Save.
-
Click Run.
The bot opens the window.
-
Specify the table.
- Double-click or drag the Recorder > Capture action.
-
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.
-
Click Capture object.
The Table (information) - Wikipedia window activates.
-
Hover over the Age table below the Basic description heading.
An orange box appears, surrounding the table.
-
Click the table.
The Object Processing message box appears.
- Return to the Control Room.
-
In the Object properties table, verify the Control Type is TABLE.
If it is not, click Recapture object.
- From the Action to take on object drop-down list, select Get table.
-
In the Save the outcome to a variable field,
create the
Tabledata
variable.
The Table (information) - Wikipedia window is saved as the variablewindow-1
. -
Specify the file where to save the data.
- Double-click or drag the Data Table > Write to file action.
-
From the Data table name list, select
Tabledata
. -
Provide a file path to create a CSV file.
For example, C:\Users\<username>\Desktop\WikipediaTable.csv.
- Select the Create folders/files if it doesn't exist option.
- Select to overwrite the existing file.
-
Close the Table (information) - Wikipedia window.
- Double-click or drag the Window > Close action.
-
Select the Variable tab and insert
window-1
.
- Click Save.
-
Click Run.
The bot creates a CSV file on the desktop with data on seven indexes, their values, and net change.