By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,956 Members | 1,722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,956 IT Pros & Developers. It's quick & easy.

file($url) problem - fulling server into thinking you're a web browser

P: n/a
Hi there,

I want to try and grab the HTML of a web page, but I have a little
problem - the web designer/developer of the page! He made it one of
those pages that displays "Please update your browser. This web site
does not support Netscape Naivagator version 1.234" if it "thinks"
your browser isn't up to par.

When I try to use PHP file($URL) function to grab the HTML, my request
doesn't have any header information informing the server what my web
browser is, so I get this message:

Is there any way to fool it my providing bogus meta/header information
in my request? Is there another solution?

Anyone have any ideas? Thanks in advance.

- Best regards,
Lee
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
lr*****@lanl.gov (Leester) wrote in message
news:<54**************************@posting.google. com>...

Is there any way to fool it my providing bogus meta/header information
in my request?


Yes. More than one, actually. You can either use cURL:

http://www.php.net/curl

or try a homebrewed solution:

$host = 'www.yourhost.com';
$path = 'path/page.htm';
$fp = fsockopen ($host, '80');
if ($fp) {
fputs($fp, 'GET '.$path." HTTP/1.0\r\nHost: ".$host."\r\n");
fputs($fp, "User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows
NT 5.0)\r\n");
} else {
die ('Oops... Nobody home...');
}
$data = '';
while (!feof ($fp)) {
$data .= fgets ($fp, 10240);
}
fclose ($fp);

Cheers,
NC
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.