Example of extracting data from a web table
- Updated: 2023/04/26
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:
-
Create a new bot:
- On the left panel, click Automation.
- Click + Create > Task Bot.
- In the Create Task Bot window, enter the bot name.
-
Accept the default folder location: \Bots\
To change the default bot storage location, click Choose and follow the prompts.
- Click Create and edit.
For information about bot naming conventions, see Create your first bot.
-
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 variable$Browser1$
. -
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
. -
In the Enter file name field, select your
file.
For example, C:\Users\<username>\Desktop\WikipediaTable.csv.
- Select to overwrite the existing file.
-
Close the Table (information) - Wikipedia window.
- Double-click or drag the Browser > Close action.
-
Select the Variable tab and insert
$Browser1$
.
- Click Save.
-
Click Run.
The bot creates a CSV file on the desktop with data on seven indexes, their values, and net change.