What is the best method for getting currency rates from a website?

Hi everyone, I need to get two different currency rates (euro and usd) from a website and then insert those values into Oracle application on a daily basis. When the website opens, it displays today’s rates as default and I need to get yesterday’s currency dates (systemdate-1) for Oracle. Because of that, robot selects the yesterday’s date and the page displays yesterday’s rates. What is the best method to copy those two numerical values?

Screen scraping methods did not work for me because the page changes everyday and page reloads with date selection. When I tried data scraping, the excel output of the datatable had wrong format for numbers(For example currency rate is 10,8234 on the website but it came as 108.234 with data scraping to excel, both the number is wrong and I need comma instead of dot). And I’m scared that if the page owners decide to add or remove some rates from their webpage, the automation would not work because I’m specifying to robot which excel cell values it should get.

What method do you suggest for my case? I am new to uipath and I have wasted so much time on this, so I really would appreciate the help, thanks

Try the get attribute activity

1 Like

Thanks for the reply, but I get an error like this:

Get Attribute ‘SPAN’: Could not find the UI element corresponding to this selector:
[1] <webctrl aaname='10,8094 ' parentid='address-5312b6def4ad0a94c5a992522868ac0a-cc51b5ce6878a3dc655dae2*' tag='SPAN'/>

Hi @alottawarmh

Can you share the website you extracted currency rates ?

HI @GreenTea

Can you please check the below website for currency conversion.

https://www.unitconverters.net/currency-converter.html

Hi @Veerabomma_Sindhura

It is a different website, it does not have yesterday exchange rate.

Does @alottawarmh website for current conversion requires a paid subscription login ?

Hi @alottawarmh

Please check out here on how to correctly change the data extraction output format.

This is the website:

http://www.bkam.ma/Marches/Principaux-indicateurs/Marche-des-changes/Cours-de-change/Cours-de-reference

Thanks for your suggestions, I’ll try them and let you know if it works or not

You can use get text activity and replace .with commma

@alottawarmh

changing the date to e.g. yesterday will have the table structure as following:

we can get the rate for USD with a get text and a finetuned selector (Done for FireFox, can easy adopt to other browsers):
grafik
Selector:

<html app='firefox.exe' title='BANK AL-MAGHRIB - Cours de référence' />
<webctrl tag='TABLE' />
<webctrl tableCol='2' tag='TD' rowName='*1 DOLLAR U.S.A.*' />

as we used the info of USD within the selector we are not bound on a particular row index

from this we receive the value as displayed on the website:
"8,9663 "

The received value we can trim and parse into a double. For doing this we do take care about the Formats and control the GroupSeperator character and the decimal character:
grafik
grafik
grafik

So we can parse the string into a double:
grafik
grafik

Later we can use the Double and get a string from it with ToString. As the format is already as we do need we do not have to reformat it. Otherwise we would take control similar as we had done for the parsing.

Find starter help here:
bkam.ma_GetUSRateFromYesterday.xaml (6.5 KB)

Kindly note: setting up a number parsing with e.g. the XXX.Parse method and providing the custom number format allows to be more reliable compared to string.replace approaches. So we do prefer

1 Like

Get Text activity was exactly what I needed, but I could not be able to do it without the correct selector. I followed your instructions and it worked absolutely perfect! Also I will consider your suggestions about formats and will work on them.

Thank you very much for your time and effort, I really appreciate it. I marked it as a solution.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.