0

I'm trying to read a simple text string from a website into my LabWindows CVI program. I've looked everywhere but can't find an example of using a simple HTTP GET request.

Does anyone know if this can be accomplished in LabWindows?

Here's the website text I'm trying to read: http://www.swpc.noaa.gov/ftpdir/latest/wwv.txt

FoppyOmega
  • 447
  • 1
  • 4
  • 17

2 Answers2

0

I have a similar application. This is my code where "WEBserviceLink" is the URL. All data is stored in "buffer" variable.

HTTPh = InternetOpenUrl (Ih, WebServiceLink, NULL, 0, INTERNET_FLAG_KEEP_CONNECTION, context);
if (!HTTPh) {
    line = __LINE__;
    error = GetLastError ();
    result = -1;
    goto Error;
}

if (!InternetQueryDataAvailable (HTTPh, &bytesRead, 0, 0)) {
    line = __LINE__;
    error = GetLastError ();
    result = -1;
    goto Error;
}

buffer = malloc (bytesRead + 3);
memset (buffer, 0, bytesRead + 3);


if (!InternetReadFile (HTTPh, buffer, bytesRead + 1, &bytesRead)) {
    line = __LINE__;
    error = GetLastError ();
    result = -1;
    goto Error;
}
0

Got it. LabWindows allows this kind of functionality through Telnet services.

First you do a "InetTelnetOpen" to open the connection.
Then you do "InetTelnetWrite" and write the "GET ..." message.
Then you do "InetTelnetReadUntil" and read until the string "/html>" to get all the site's text.

LabWindows truly is an awful, poorly documented language.

FoppyOmega
  • 447
  • 1
  • 4
  • 17
  • InetTelnetOpen() is returning -22 error type (couldnt connect), but i tested URL and connection in C#, what kind of aspects could be a reson? –  Sep 04 '12 at 02:32
  • For the website above I used "telnetHandle = InetTelnetOpen("nos-ssmc2.woc.noaa.gov", 80, 0);" to connect. It was over a year ago, but it looks like I connected to the DNS rather than the url or something. – FoppyOmega Sep 04 '12 at 20:01
  • Regarding your comment "LabWindows truly is an awful, poorly documented language", It is simply ANSI C, probably THE most documented programming language in history. However, It is also shipped with more extended libraries for instrument control than I have seen in any other C Integrated development kit. Very useful if you are doing anything with measurement equipment. Just keeping it real. – ryyker Aug 20 '13 at 15:06