FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Fetching an external web page
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Fetching an external web page [message #171407 is a reply to message #171231] Sat, 01 January 2011 23:59 Go to previous messageGo to previous message
dog_cow is currently offline  dog_cow
Messages: 2
Registered: November 2010
Karma:
Junior Member
Mike wrote:
>
> How can I do it with just one call?

Open a socket with fsockopen() to port 80. Then use fputs() to send an HTTP
request. Use fgets() to read the response. Finally, use fclose() to destroy
the socket. This response will include everything that you have asked about,
which you must then parse on your own.

Here is a little example:


<?php

$sock = fsockopen('php.net', 80);

fputs($sock, "GET / HTTP/1.1\r\nHost: php.net\r\nUser-Agent:
Firefox\r\nConnection: close\r\n\r\n");

while(($buf = fgets($sock, 4096)) !== false)
{
echo $buf;
}

fclose($sock);

?>

--
Mac GUI Vault - A source for retro Apple II and
Macintosh computing.
http://macgui.com/vault/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Failed to write to a text file (text file is RW)
Next Topic: PHP Bug + Hotfix
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 14:23:19 GMT 2024

Total time taken to generate the page: 0.03930 seconds