Hello...
i want to grab the currency value from bloomberg, this is a part of bloomberg html. I want to get USD-SGD value, in this time the value is 1.5198. How can i grab it using c language?
please help me, because after this, i will translate to dynamic c...

<td bgcolor="#D2E1E8">NZD-USD</td>
<td bgcolor="#D2E1E8" align="right">0.7388</td>
<td bgcolor="#D2E1E8" align="right">
<span class="changedown">-0.0032</span></td>
<td bgcolor="#D2E1E8" align="right">
<span class="changedown">-0.4313%</span></td>
<td bgcolor="#D2E1E8" align="right">00:23</td>
</tr>

<tr>
<td bgcolor="white">USD-SGD</td>
<td bgcolor="white" align="right">1.5198</td>
<td bgcolor="white" align="right">
<span class="changeup">0.0038</span></td>
<td bgcolor="white" align="right">
<span class="changeup">0.2540%</span></td>
<td bgcolor="white" align="right">00:23</td></tr>

thanks in advance

Dani AI

Generated

Short, practical plan that fits the RCM3200 + Dynamic C constraints:

  • Open a TCP connection to the web host (port 80) and send a minimal HTTP GET. As noted, the device talks raw TCP.
  • Avoid a full HTML parser on the microcontroller. As suggested, use a tiny streaming string-match: search the incoming bytes for the currency label (e.g. USD-SGD) and then capture the next numeric token. This keeps RAM use low and works for stable HTML.
  • If you control no server-side piece and the site requires TLS or returns compressed/chunked responses, a tiny proxy on a PC or VPS that fetches, cleans and returns plain text is the reliable alternative (see notes below). ’s tip about serving plain text from port 80 aligns with this.

Example streaming extractor (conceptual; adapt to your Dynamic C socket API):

/* read from sock byte-by-byte with recv(); returns 1 on success */
int extract_after_label(int sock, const char *label, char *out, size_t outlen)
{
    size_t lablen = strlen(label), match = 0, pos = 0;
    char ch; int r;
    while ((r = recv(sock, &ch, 1, 0)) == 1) {
        if (!match) {
            if (ch == label[0]) match = 1;
            continue;
        }
        if (ch == label[match]) { match++; if (match == lablen) break; continue; }
        match = (ch == label[0]) ? 1 : 0;
    }
    /* skip until first numeric char */
    while ((r = recv(sock, &ch, 1, 0)) == 1 && !( (ch>='0' && ch<='9') || ch=='-' || ch=='.' ));
    if (r != 1) return 0;
    /* collect number */
    do {
        if (pos+1 < outlen && ((ch>='0' && ch<='9') || ch=='.' || ch==',')) out[pos++]=ch;
        else break;
    } while ((r = recv(sock, &ch, 1, 0)) == 1);
    out[pos]=0;
    return pos ? 1 : 0;
}

Practical cautions and debugging tips:

  • Many modern sites require HTTPS or send gzip/chunked content. If the device cannot do TLS or decompression, use a small proxy that returns plain text.
  • Test first from a PC: print raw HTTP headers and body, confirm status 200 and encoding, then adapt the microcontroller code.
  • Make the label comparison case-insensitive or resilient to small HTML changes, and validate the captured token (digits + optional dot) before using it.

This approach is compact, tolerant of limited RAM, and easy to debug from a PC before porting to Dynamic C on the RCM3200.

Recommended Answers

All 4 Replies

You could write a full-blown HTML parser, you could use somebody else's HTML parser, or you could use a cheapo solution that looks for strings like NZD-USD and walks their way forward through values.

And you'll need to grab the page from the webserver, too.

I'm not sure what you're asking -- is there some particular part of this process you need help with?

i think you can connect to the page via sockets programming in c.
and then try parsing the page like seaching the currency values.

i using microprocessor RCM3200 for server, so i don't using computer. The microprocessor just using dynamic c. I think i can see html as text, so i can parse it.
anyone has a sample script similar/like my problem?

thank you...

I work with rcm3200 and i work with HTML, only send the text
by the port 80 like a tcp string. you don't need format the text... ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.