Home >Backend Development >PHP Tutorial >Example of fsockopen collecting web content in php_PHP tutorial
fsockopen is a relatively practical function in PHP. Now I will introduce the program that uses the fsockopen function to collect web pages. Friends in need can refer to it.
Usage
int fsockopen(string hostname, int port, int [errno], string [errstr], int [timeout]);
An example of collecting web pages
The code is as follows
|
Copy code { $query = $url[path] ."?".$url[query]; $fp = fsockopen( $url[host], $url[port]?$url[port]:80 , $errno, $errstr, 30); $fp = fsockopen($host, 80, $errno, $errstr, 30); |
$request.=”rn”;
{$body= stristr($rowdata,”rnrn ”);The code is as follows | Copy code |
$ fp = fsockopen($host, 80, $errno, $errstr, 30);or$fp = fsockopen($host, $port, $errno, $errstr, $connection_timeout);Modify After:$fp = stream_socket_client("tcp://".$host."80", $errno, $errstr, 30);or$fp = stream_socket_client("tcp:// ".$host.":".$port, $errno, $errstr, $connection_timeout); http://www.bkjia.com/PHPjc/444623.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444623.htmlTechArticlefsockopen is a more practical function in php. Let me introduce the program that uses the fsockopen function to collect web pages. Friends in need can refer to it. Usage int fsockopen(string hostn... |