How to store variables from websites and how to create excel file from your variables?

Hi there,

Can anyone in this forum help me solve this problem?
I would like to store some data on the website and save them as variables. Then, reuse the variables as well as save those variables in the excel file.

My plan is to use data scraping. But how can I save each piece of information as variable?

Thank you,

1 Like

Create variables for all of the values that you need. They should show up in the Variables pane in studio.

Then, in your data scraping activities there should be a place to put an output variable. Depending on how you’re scraping it may be called Value or Text. Put the variables in here and then they will have the value of the scraped data.
image

1 Like

Thank you. But how do I built the table base on these variables

1 Like

When you run the Data Scraping wizard it should generate a table with the results in it.
image

Then you can use a Write Range activity inside of an Excel Scope to write the scraped contents to an excel file. If there is any other data that isn’t automatically scraped by the wizard then you’ll need to manually scrape that and then place it into the corresponding entry in the datatable.

Let’s say you want to set the first column of the first row to “A”. You can say ExtractDataTable(0)(0) = “A”. Just substitute “A” with your variable. If you need to add a row to the table you can do so with the Add Data Row activity.

1 Like

I want to create the excel file manually with different variables in it. How do I do that?

1 Like

Something like this.

  • Creates a datatable called myDataTable. Mine just has two columns, one for strings and one for ints.
    image

  • Adds rows to it
    image

  • Writes to myWorkbook.xlsx, Sheet1, Cell A1
    image

The key difference will be that instead of simply adding two rows you will have to loop through your data and add as many as are necessary.

1 Like

Thank you. But I still can’t insert my store variables. I tried to put it on “DataRow” but it gave me error

1 Like

Make sure the variable’s type is DataRow.

2 Likes

Thank you

2 Likes

You’re welcome! Is it working for you?

1 Like

Well, I am trying create the variables from the website. but it didn’t give me Text Output option. It only gave me DataTable Output

1 Like

If it’s giving you a DataTable output you can either:
a) merge the output table with yours to preserve records that are in your table
b) overwrite your table with the output

1 Like

Just a recap, We use the Data Scraping with the output set to variable, then use Built Data Table with Add Data Row in the DataRow field add variables?

1 Like

I couldn’t make it work.

1 Like

Yes, if you use the Extract Structured Data activity it will give you a variable with type DataTable. If that variable is the same as the table you created with Build Data Table then the data that was extracted will overwrite the variable. If it is a different variable than the one you built you can use Merge Data Table to join the tables, but the number and variable types of the columns must match up.

Alternatively, if you are NOT using the Extract Structured Data activity and you just have values stored in variables you can use the Add Data Row activity to add the data manually to your table. To do this it must be either an ArrayRow or a DataRow. To make it an ArrayRow you can type {var1,var2,var3} where var1, etc are your variables.

If the website that you’re scraping isn’t private/confidential could you link it? That might help us help you better.

I cannot share the website because it’s confidential. But I tried your method but it’s not working. I am not sure what I did wrong.

Do you have different methods to store variables?

I’ve attached a workflow with two examples. The first one uses the data scraping wizard to get data and then writes it to excel. The second one uses the Get text activity to scrape some values, store them as variables, add them to a datatable, and then write it to excel.

Main.xaml (13.7 KB)

Thank you very much!! It works. Now I just have to figure it out the way to loop the variables