简体   繁体   English

您如何在LabWindows CVI中从网站阅读文本?

[英]How do you read text from a website in LabWindows CVI?

I'm trying to read a simple text string from a website into my LabWindows CVI program. 我正在尝试从网站中读取一个简单的文本字符串到LabWindows CVI程序中。 I've looked everywhere but can't find an example of using a simple HTTP GET request. 我到处都看过,但是找不到使用简单HTTP GET请求的示例。

Does anyone know if this can be accomplished in LabWindows? 有谁知道这可以在LabWindows中完成吗?

Here's the website text I'm trying to read: http://www.swpc.noaa.gov/ftpdir/latest/wwv.txt 这是我要阅读的网站文字: http : //www.swpc.noaa.gov/ftpdir/latest/wwv.txt

I have a similar application. 我有一个类似的应用程序。 This is my code where "WEBserviceLink" is the URL. 这是我的代码,其中“ WEBserviceLink”是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;
}

Got it. 得到它了。 LabWindows allows this kind of functionality through Telnet services. LabWindows通过Telnet服务允许这种功能。

First you do a "InetTelnetOpen" to open the connection. 首先,您执行“ InetTelnetOpen”以打开连接。
Then you do "InetTelnetWrite" and write the "GET ..." message. 然后,您执行“ InetTelnetWrite”并编写“ GET ...”消息。
Then you do "InetTelnetReadUntil" and read until the string "/html>" to get all the site's text. 然后,您执行“ InetTelnetReadUntil”并阅读直到字符串“ / html>”以获取所有站点文本。

LabWindows truly is an awful, poorly documented language. LabWindows确实是一种糟糕的文档,缺乏文献报道。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM