You are here: Re: Read a website with Fopen() « PHP Programming Language « IT news, forums, messages
Re: Read a website with Fopen()

Posted by petersprc on 11/30/07 11:31

Hi,

You can adjust the User-Agent header like so:

ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.1.10) Gecko/20071115 Firefox/2.0.0.10');

Then fetch a page:

$doc = file_get_contents('http://example.net');

If you want to implement a mirror, you can use mod_proxy and
mod_proxy_html. For example:

ProxyPass /my/mirror/ http://example.net/

If you want to store locally a page and associated images and scripts,
you can use wget with the -p option:

wget -p http://example.net

On Nov 30, 6:01 am, zenner <pro.ra...@hotmail.com> wrote:
> Hello.
> when i try to "read" some websites with fopen() some of them allow but
> some don't
> Does the server knows that it´s not a web browser that it's trying to
> access?
> How can i solve this??
>
> Below is an example of a site that gives an error when you try to read
> it.
>
> <?php
> $file="http://www.radios.pt/portalradio/";
> $fp = fopen($file, "r");
> while (!feof($fp))
> {
> $a=$a.fgets($fp);}
>
> fclose($fp);
> echo $a;
> ?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация