1

我有一个每秒记录数据的硬件。我可以通过浏览器连接到硬件并使用硬件接口获取实时数据。例如:我可以使用如下命令调用实时数据:

http://192.168.100.120:2345/realtime 

这就是我在浏览器中看到的:

DM_NumLogChans=5
DM_NumDataModes=1

DM_LogicalChan=1
DM_ChanType=SEQUENTIAL
DM_NumDims=2
DM_DataMode=1
DM_DataModeType=TIMHIS
DM_AxisLabel.Dim1=Time
DM_AxisLabel.Dim2=Value
DM_AxisUnits.Dim1=secs
DM_AxisUnits.Dim2=microstrain
DM_SampleRate=1.000000
DM_TimeBase=0.0
DM_ChanName=bridge_1
DM_UserMin=-583.220764
DM_UserMax=940.916199


DM_Start=
-439.779    -391.875    -680.114    1001.37 0
-442.068    -396.62 -680.945    1001.37 0
-443.571    -399.705    -680.639    1001.37 0
-445.598    -404.848    -684.662    1001.37 0

每秒钟出现一个新行。我想获取这些数据并将其保存到文件中或在我的 php 程序中实时显示。我怎样才能捕捉到数据?我试过卷曲。我认为这是解决方案,但我对此真的很陌生。如果您能给我任何帮助或建议,我将不胜感激。

4

1 回答 1

1

使用您的网址尝试此代码

function curl_download($Url){

    // is cURL installed yet?
    if (!function_exists('curl_init')){
        die('Sorry cURL is not installed!');
    }

    // OK cool - then let's create a new cURL resource handle
    $ch = curl_init();

    // Now set some options (most are optional)

    // Set URL to download
    curl_setopt($ch, CURLOPT_URL, $Url);

    // Set a referer
    curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm");

    // User agent
    curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");

    // Include header in result? (0 = yes, 1 = no)
    curl_setopt($ch, CURLOPT_HEADER, 0);

    // Should cURL return or print out the data? (true = return, false = print)
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // Timeout in seconds
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);

    // Download the given URL, and return output
    $output = curl_exec($ch);

    // Close the cURL resource, and free system resources
    curl_close($ch);

    return $output;
}




echo curl_download("192.168.100.120:2345/realtime");
于 2013-10-01T08:44:30.670 回答