How to download data from web pages with the AUTOMADE tool?

How to download data from web pages with the AUTOMADE tool?

Downloading data from pages into worksheets is a common and tedious task in many companies, so it’s perfect for automation. By delegating this type of task to a robot, employees gain a lot of valuable time and eliminate the risk of error from the process.

In this article we describe how to retrieve data from websites.

What kind of data can be downloaded with the AUTOMADE robot?

Automating the retrieval of data from websites can involve a myriad of information, such as exchange rates, stock market results, or various statistical data. Any information from websites that is in tables can be automatically imported into Excel files with the help of the AUTOMADE robot.

How to download data from pages?

Creating a macro to retrieve data from pages is very simple. We will explain the process using the example of downloading currency rates from a table on the National Bank of Poland website.

Our task will be to record the copying of the first currency name, code and rate value and then create a loop in the robot that repeats this action on all rows of the table. As you can see in this case, we will need to record copying information:

  • Name of the currency (bat Thailand)
  • Currency code (1 THB)
  • Average exchange rate (0,1251)

1. Start recording

The first step in creating such a macro is, of course, to start recording with the Record button.

 

Note: once recording has started, avoid any unnecessary clicks. They may prevent the macro from playing properly.

 

So prepare the web addresses and files that will be used in your macro, as well as your login details if you need them.

2. Starting an Excel sheet

First, create a blank Excel sheet into which you will then copy the values from the table on the NBP site.

 

To start a blank worksheet, press the Record Tools button and select Open File.

 

3. Launching the robot’s browser or Google Chrome

The AUTOMADE robot is compatible with two browsers – WebView embedded in the tool or Google Chrome. You can use either of them.

 

To launch the browser, press the Record Tool button and select Open Browser.

4. Go to the website where the data is located

You can go directly to the link where the data is located or start from the home page. In this case, just type “nbp.pl” and go to the “Table A” link.

 

Once you are on the data page, copy all the data from the first row into an Excel sheet one by one. As we mentioned, in the case of exchange rates from the NBP website, it will be the name, code and rate of the currency.

 

In the Excel sheet, the data will look as follows:

5. Stop recording

After copying the first line, stop recording. At this point the macro will of course only perform the operations that have been recorded.

To start copying all currencies from the table, create a loop.

6. Creating a loop in recordset

The AUTOMADE robot detects the table on the page as a dataset, so in order for it to repeat the actions for the following rows, you need to select the steps you want to repeat and select the option from the advanced view “Repeat on dataset”. In this case it will be the following steps:

 

The steps repeated in a loop will be grouped into a block. The robot will repeat these steps until the table on the page runs out of data.

7. Saving an Excel document with a specific name

A correctly created loop will make the AUTOMADE robot fill the Excel document with all the content from the page. All that remains is to save the file and set a name for it.

 

To do this, use the Add step function in the advanced view and add the “Generate file name” step to the graph. In the file name, you can, for example, specify today’s date.

 

If you want a file with a date in the name, you will have to use the Generate date step. To add such a step, which you will also find in the list of available steps, click Add step.

In the step editing options, set the date format and set the variable name. Then use this variable as the name or part of it in the “Generate file name” step.

 

Once the name is set, the robot will already have all the necessary steps to:

  • Run the web page with the data
  • Copy the data into an Excel sheet
  • Repeat the action for all the rows in the table
  • Save the excel file with the established name