Re: Retrieving web pages
| From: | Ernest E Vogelsinger | Date: | Sat, 03 May 2003 10:15:48 +0000 |
| Subject: | Re: Retrieving web pages | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146247@lists.php.net to get a copy of this message | ||
At 23:31 02.05.2003, Mark Douglas said:
--------------------[snip]--------------------
>I'm trying to figure out a way of retrieving the contents of web pages with
>PHP. Currently I'm using the sockets example from php's site -
>http://www.php.net/manual/en/ref.sockets.php - I've
>modified the "one-shot
>HTTP client" so that instead of just a head request it does a get. However,
>with this method I get the headers as well as the page content. Help either
>in stripping the headers, or using a different method to load page contents
>would be greatly appreciated. Note that I don't want to just display the
>contents, I want to be able to store it in a variable, or ultimately, a BLOB
>column in a MySQL column.
--------------------[snip]--------------------
You may simply fopen() any remote URL, if allow_url_fopen is enabled on
your server (see http://www.php.net/manual/en/function.fopen.php
for more
information). This will you get the page contents without the headers.
You may also use cURL to retrieve a page, also via https. This gives you a
finer granularity over your request.
If you need to strip the headers look for the first occurrence of "\n\n" in
the response. Before are the headers, after that is the response content.
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/