How to strip header section from an HTML page?

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

    How to strip header section from an HTML page?

    I have an html page returned from a curl session in a variable. I want to
    strip off the header portion of the file and replace with a new header.

    It seemed to me that this is probably a well-known thing to want to do, but
    before I try to write the code myself, anyone have any code examples of how
    to do this?

    Thanks!
    --
    Stephen Kay
    Karma-Lab sk@karma-lab.NOSPAM.com
    ^^^^^^^


  • Oli Filth

    #2
    Re: How to strip header section from an HTML page?

    Stephen Kay said the following on 28/03/2006 18:59:[color=blue]
    > I have an html page returned from a curl session in a variable. I want to
    > strip off the header portion of the file and replace with a new header.
    >[/color]

    CURLOPT_HEADER



    --
    Oli

    Comment

    • Dave

      #3
      Re: How to strip header section from an HTML page?

      You can either do:

      1.)
      curl_setopt($ch , CURLOPT_HEADER, 1);
      curl_setopt($ch , CURLOPT_NOBODY, 1);
      $headers=curl_e xec($ch);
      curl_close($ch) ;

      or
      2.) if you also need the html part:

      curl_setopt($ch , CURLOPT_HEADER, 1);
      curl_setopt($ch , CURLOPT_RETURNT RANSFER,1);
      $source = curl_exec($ch);
      curl_close($ch) ;

      // then split the returned source at adistinct place such as: <!DOCTYPE...
      $source_array=s plit("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
      Transitional//EN\">",$source) ;
      $headers=$sourc e_array[0];
      // add back the string we used to split the source:
      $html="<!DOCTYP E HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">" .
      $source_array[1];


      "Stephen Kay" <sk@karma-lab.nospam.com> wrote in message
      news:C04EE2FA.5 ADD5%sk@karma-lab.nospam.com. ..[color=blue]
      >I have an html page returned from a curl session in a variable. I want to
      > strip off the header portion of the file and replace with a new header.
      >
      > It seemed to me that this is probably a well-known thing to want to do,
      > but
      > before I try to write the code myself, anyone have any code examples of
      > how
      > to do this?
      >
      > Thanks!
      > --
      > Stephen Kay
      > Karma-Lab sk@karma-lab.NOSPAM.com
      > ^^^^^^^
      >
      >[/color]


      Comment

      Working...