|
Posted by Dave on 11/18/22 11:43
You can either do:
1.)
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
$headers=curl_exec($ch);
curl_close($ch);
or
2.) if you also need the html part:
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$source = curl_exec($ch);
curl_close($ch);
// then split the returned source at adistinct place such as: <!DOCTYPE...
$source_array=split("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">",$source);
$headers=$source_array[0];
// add back the string we used to split the source:
$html="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">" .
$source_array[1];
"Stephen Kay" <sk@karma-lab.nospam.com> wrote in message
news:C04EE2FA.5ADD5%sk@karma-lab.nospam.com...
>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
> ^^^^^^^
>
>
Navigation:
[Reply to this message]
|