reading an html page.

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

    reading an html page.

    Hi,
    I have a database that have all my dell desktop with the dell serial number.
    I would like to update my database with the ship date from this url:


    How can i easily get only the date from all this html page??
    Thanks for your ideas.
    VooDoo


  • Mladen Gogala

    #2
    Re: reading an html page.

    On Mon, 13 Mar 2006 16:00:45 +0100, VooDoo wrote:
    [color=blue]
    > Hi,
    > I have a database that have all my dell desktop with the dell serial number.
    > I would like to update my database with the ship date from this url:
    > http://support.euro.dell.com/support...iceTag=1DTDD0J
    >
    > How can i easily get only the date from all this html page??
    > Thanks for your ideas.
    > VooDoo[/color]

    #!/usr/local/bin/php
    <?php
    $url = 'http://tinyurl.com/qfehg';
    $match = array();
    $FILE = fopen($url, 'r');
    while ($line = fread($FILE, 1024)) {
    if (preg_match('/ship date:.*(\d{2}\/\d{2}\/\d{4})/i', $line, $match)) {
    echo "Ship date is:", $match[1], "\n";
    fclose($FILE);
    break;
    }
    }
    ?>


    Ship date is extracted. How are you going to update database and
    what database are you talking about is another matter indeed. This
    was a really simple programming exercise.


    --


    Comment

    • Jerry Stuckle

      #3
      Re: reading an html page.

      Mladen Gogala wrote:[color=blue]
      > On Mon, 13 Mar 2006 16:00:45 +0100, VooDoo wrote:
      >
      >[color=green]
      >>Hi,
      >>I have a database that have all my dell desktop with the dell serial number.
      >>I would like to update my database with the ship date from this url:
      >>http://support.euro.dell.com/support...iceTag=1DTDD0J
      >>
      >>How can i easily get only the date from all this html page??
      >>Thanks for your ideas.
      >>VooDoo[/color]
      >
      >
      > #!/usr/local/bin/php
      > <?php
      > $url = 'http://tinyurl.com/qfehg';
      > $match = array();
      > $FILE = fopen($url, 'r');
      > while ($line = fread($FILE, 1024)) {
      > if (preg_match('/ship date:.*(\d{2}\/\d{2}\/\d{4})/i', $line, $match)) {
      > echo "Ship date is:", $match[1], "\n";
      > fclose($FILE);
      > break;
      > }
      > }
      > ?>
      >
      >
      > Ship date is extracted. How are you going to update database and
      > what database are you talking about is another matter indeed. This
      > was a really simple programming exercise.
      >
      >[/color]

      And this will fail if the ship date spans a 1024 byte block.

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • Geoff Berrow

        #4
        Re: reading an html page.

        Message-ID: <pan.2006.03.14 .04.09.26.39592 @sbcglobal.net> from Mladen
        Gogala contained the following:
        [color=blue]
        >This
        >was a really simple programming exercise.[/color]

        This was an unnecessary comment. Simple is relative.

        --
        Geoff Berrow (put thecat out to email)
        It's only Usenet, no one dies.
        My opinions, not the committee's, mine.
        Simple RFDs http://www.ckdog.co.uk/rfdmaker/

        Comment

        • VooDoo

          #5
          Re: reading an html page.

          I agree...
          Great Thanks anyway to your answers.
          I gonna try this right now
          VooDoo
          "Geoff Berrow" <blthecat@ckdog .co.uk> a écrit dans le message de news:
          k6rc12tcpj0q5lv 0ohj7npu09r7usb 1q3n@4ax.com...[color=blue]
          > Message-ID: <pan.2006.03.14 .04.09.26.39592 @sbcglobal.net> from Mladen
          > Gogala contained the following:
          >[color=green]
          >>This
          >>was a really simple programming exercise.[/color]
          >
          > This was an unnecessary comment. Simple is relative.
          >
          > --
          > Geoff Berrow (put thecat out to email)
          > It's only Usenet, no one dies.
          > My opinions, not the committee's, mine.
          > Simple RFDs http://www.ckdog.co.uk/rfdmaker/[/color]


          Comment

          • Mladen Gogala

            #6
            Re: reading an html page.

            On Mon, 13 Mar 2006 23:17:22 -0500, Jerry Stuckle wrote:
            [color=blue]
            > And this will fail if the ship date spans a 1024 byte block.[/color]

            Which it doesn't. I looked at the page. In this case, it doesn't
            matter, but I am reluctant to use fscanf("%s\n") as it may result
            in buffer overrun. It's a habit acquired by programming in C.

            --


            Comment

            • Bart the bear

              #7
              Re: reading an html page.


              Geoff Berrow wrote:[color=blue]
              > Message-ID: <pan.2006.03.14 .04.09.26.39592 @sbcglobal.net> from Mladen
              > Gogala contained the following:
              >[color=green]
              > >This
              > >was a really simple programming exercise.[/color]
              >
              > This was an unnecessary comment. Simple is relative.[/color]

              Everything in life is relative. Duration of a minute depends on the
              side of bathroom door you're currently on. This, however, was simple
              and can be done after 2 hours of reading any "PHP in 24 hours" book.
              This was the mildest form of reproach that I've ever seen. If the OP
              wants
              to program in any scripting language, he must be able and willing to
              program snippets like that without pestering people on the internet.
              I simply skip questions like this and don't answer them. Mladen has
              answered and added a very mild comment, which is something that he's
              completely entitled to, at least in my opinion.

              Comment

              • Jerry Stuckle

                #8
                Re: reading an html page.

                Mladen Gogala wrote:[color=blue]
                > On Mon, 13 Mar 2006 23:17:22 -0500, Jerry Stuckle wrote:
                >
                >[color=green]
                >>And this will fail if the ship date spans a 1024 byte block.[/color]
                >
                >
                > Which it doesn't. I looked at the page. In this case, it doesn't
                > matter, but I am reluctant to use fscanf("%s\n") as it may result
                > in buffer overrun. It's a habit acquired by programming in C.
                >[/color]

                It doesn't *currently*. This is exactly the type of thinking which will
                come back to bite you eventually. Suddenly it fails - "But I didn't
                change anything...". And you didn't. But someone else did.

                And trying to find the problem two years (or even two months) from now
                could be *very* difficult.

                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===

                Comment

                Working...