reading

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Follet

    reading

    Hi,

    I must read an HTML-free web page. The only documentation I have is this : :

    temp: This request will return an HTML-free web page, consisting of a
    simple ASCII string of pipe-delimited data. The data will be in the
    format of :

    "PROBE1_NAME|TE MP|PROBE2_NAME| TEMP…"

    How can I do ?

    Thanks
  • Erwin Moller

    #2
    Re: reading

    Richard Follet wrote:
    [color=blue]
    > Hi,
    >
    > I must read an HTML-free web page. The only documentation I have is this :
    > :
    >
    > temp: This request will return an HTML-free web page, consisting of a
    > simple ASCII string of pipe-delimited data. The data will be in the
    > format of :
    >
    > "PROBE1_NAME|TE MP|PROBE2_NAME| TEMP…"
    >
    > How can I do ?
    >
    > Thanks[/color]

    Hi,

    What is it you want to do with that data?
    Do you want it displayed on a HTML-containing webpage?

    if so: use explode


    eg:

    mysterystring = "PROBE1_NAME|TE MP|PROBE2_NAME| TEMP…";
    $parts =


    Comment

    • Erwin Moller

      #3
      Re: reading

      Erwin Moller wrote:
      [color=blue]
      > Richard Follet wrote:
      >[color=green]
      >> Hi,
      >>
      >> I must read an HTML-free web page. The only documentation I have is this
      >> :
      >> :
      >>
      >> temp: This request will return an HTML-free web page, consisting of a
      >> simple ASCII string of pipe-delimited data. The data will be in the
      >> format of :
      >>
      >> "PROBE1_NAME|TE MP|PROBE2_NAME| TEMP…"
      >>
      >> How can I do ?
      >>
      >> Thanks[/color]
      >
      > Hi,
      >
      > What is it you want to do with that data?
      > Do you want it displayed on a HTML-containing webpage?
      >
      > if so: use explode
      > http://nl2.php.net/manual/en/function.explode.php
      >
      > eg:
      >
      > mysterystring = "PROBE1_NAME|TE MP|PROBE2_NAME| TEMP…";
      > $parts =[/color]

      Sorry, my KNode decided to post without my permission. :-(

      This is what I wanted to write:

      $mysterystring = "PROBE1_NAME|TE MP|PROBE2_NAME| TEMP…";
      $parts = explode("|" , $mysterystring) ;

      Now parts[0] is PROBE1_NAME
      parts[1] is TEMP
      parts[2] is PROBE2_NAME
      etc.

      Good luck.

      Regards,
      Erwin Moller


      Comment

      • Steve

        #4
        Re: reading

        [color=blue]
        > I must read an HTML-free web page. The only documentation I have is this : :[/color]

        I assume you have one of these:


        This was discussed in here a while ago, the product uses a built-in
        mini-server that doesn't send any headers with the data. This means you
        can't use any PHP functions that need headers to assist access to the
        data. The solution is to use fsockopen and manually send a GET request:


        $fp = fsockopen( $IP, 80, $errno, $errstr, 30 );
        if (!$fp) {
        echo "$errstr ($errno)<br />\n";
        } else {
        $out = "GET /temp/ HTTP/1.1\r\n";
        $out .= "Host: $IP\r\n";
        $out .= "Connection : Close\r\n\r\n";

        fwrite($fp, $out);
        while (!feof($fp)) {
        echo fgets($fp, 128);
        }
        fclose($fp);
        }

        For the full text see:



        (or search groups on "comp.lang. php" "temperatur e sensor")

        ---
        Steve

        Comment

        • Richard Follet

          #5
          Re: reading

          Thank you very much !

          Steve a écrit :
          [color=blue]
          >I assume you have one of these:
          >http://www.sensatronics.com/products_modelecom.php
          >
          >This was discussed in here a while ago, the product uses a built-in
          >mini-server that doesn't send any headers with the data. This means you
          >can't use any PHP functions that need headers to assist access to the
          >data. The solution is to use fsockopen and manually send a GET request:
          >
          >
          >$fp = fsockopen( $IP, 80, $errno, $errstr, 30 );
          >if (!$fp) {
          > echo "$errstr ($errno)<br />\n";
          >} else {
          > $out = "GET /temp/ HTTP/1.1\r\n";
          > $out .= "Host: $IP\r\n";
          > $out .= "Connection : Close\r\n\r\n";
          >
          > fwrite($fp, $out);
          > while (!feof($fp)) {
          > echo fgets($fp, 128);
          > }
          > fclose($fp);
          >}
          >
          >For the full text see:
          >
          >http://groups.google.co.uk/group/com...ef?tvc=2&hl=en
          >
          >(or search groups on "comp.lang. php" "temperatur e sensor")
          >
          >---
          >Steve
          >
          >
          >[/color]

          Comment

          • nop

            #6
            Re: reading

            Richard Follet wrote:[color=blue]
            > Hi,
            >
            > I must read an HTML-free web page. The only documentation I have is this
            > : :
            >
            > temp: This request will return an HTML-free web page, consisting of a
            > simple ASCII string of pipe-delimited data. The data will be in the
            > format of :
            >
            > "PROBE1_NAME|TE MP|PROBE2_NAME| TEMP…"
            >
            > How can I do ?
            >
            > Thanks[/color]

            Do you mean something like following ?

            $txt = file_get_conten ts('http://www.somewhere.n et/page.html');
            $token = explode ('|', $txt);
            var_dump ($token);

            Comment

            Working...