473,386 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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
^^^^^^^
Mar 28 '06 #1
2 3107
Stephen Kay said the following on 28/03/2006 18:59:
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.


CURLOPT_HEADER

--
Oli
Mar 28 '06 #2
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:C0***************@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
^^^^^^^

Mar 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: will | last post by:
Dear All, can anyone help here? I need to use XML/XSLT to print out some documents which must all have the same letterhead and footer section on all pages. The section in between is dynamic XML,...
3
by: Prakash Wadhwani | last post by:
In a report I have 3 sub-reports. Each Sub-Report has it's own Page Header. When I run the sub-reports individually, the page headers print correctly ... but ... when I run the main report the...
2
by: Salad | last post by:
Is there a way to determine which section of a form a control is located in code....besides using the tag property?
2
by: Ross Hamilton | last post by:
Can anyone help me with this small problem. I have a report that is divided into 3 Columns using the page setup, It displays the report fields in 3 separate columns (Desc & Pg Num) but it only...
3
by: Michal A. Valasek | last post by:
Hello, I want to transform text with HTML markup to plain text. Is there some simple way how to do it? I can surely write my own function, which would simply strip everything with < and >....
1
by: Steve Franks | last post by:
OK this is driving me nuts - hope someone can help. I am searching for a way to dynamically output a value within the HeaderTemplate section of a Repeater control. Is this possible? It is...
0
by: Arnold | last post by:
Hi Everyone; In a report, I've essentially recreated a paper sheet by adding various labels--name, date, problem, year, Progress Notes, etc.--and horizontal lines (people have traditionally...
0
by: LemonHead | last post by:
I have a report with a header and 2 sub-reports in the detail section. When I select "Repeat Section" to "Yes" in the main report, the header repeats multiple times with nothing else on the page. ...
1
by: franc sutherland | last post by:
Hi, I am using Access 2003. I have set up an invoice in a report. I have set up the name and address as text boxes in the Page Header which I've made as small as possible then set the Can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.