1

I need to get currency values from https://www.bcr.ro/en/exchange-rates but getting html string with these methods:

  1. WebRequest req = HttpWebRequest.Create("https://www.bcr.ro/en/exchange-rates");
    req.Method = "GET";
    
    string source;
    using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream()))
    {
        source = reader.ReadToEnd();
    }
    
  2. WebClient wc = new WebClient();
    string s = wc.DownloadString("https://www.bcr.ro/en/exchange-rates");
    

Both are resulting in getting a weird html string, which not contains desired data:

<!DOCTYPE html>
<html  lang="en" class="no-js false_EAM isEmil_false">
<!-- Version: 2.16.7.0 (gportals2m1pvm1-044457035960000082024075) Date: 24.10.2015 18:19:59 -->
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Exchange rates | BCR</title>
  <link rel="shortcut icon" type="image/x-icon" href="https://www.bcr.ro/content/8ea9dd8a/-3b9c-429b-9f72-34e75b7512e3/favicon.ico">
  <meta name="author" content="Banca Comerciala Romana (BCR): loans, cards, deposits, Internet Banking, current account">
  <meta name="description" content="Banca Comerciala Romana (BCR), a member of Erste Group, is a universal bank serving both retail and corporate clients. ">
  <meta name="generator" content="Group Portal - 2.16.7.0"><meta name="keywords" content=" loans, cards, deposits, Internet Banking, current account">

How could I achieve wanted result?

wittich
  • 2,079
  • 2
  • 27
  • 50
meta4
  • 788
  • 1
  • 10
  • 24

2 Answers2

1

So after a quick research, the answer is pretty simple:

  1. Both WebRequest and WebClient with initiallink pull the data contained in source of page which is Crtl+U, which does not contain desired data
  2. After a quick search in DEV (Crtl+F12) it was clear that desired data was brought dynamically, so after a look in Network TAB I found the request (data) which was pulling exact desired data in a beautiful JSON (perfect).
meta4
  • 788
  • 1
  • 10
  • 24
-1

Try to create a RegEx that grabs this out ('<table class="overview glaze fullsize">') and then grabs everything in this tag of the HTML page. Then use it where needed.

Sam
  • 7,252
  • 16
  • 46
  • 65
Stefan van de Laarschot
  • 2,154
  • 6
  • 30
  • 50