做的网站电脑上跟手机上不一样,好玩的游戏网页,wordpress中文是什意思,七牛搭建网站步骤#xff1a;1#xff0c;匹配URL中的主机名和文件部分2#xff0c;创建socket并连接到目标服务器3#xff0c;构造HTTP请求并发送4#xff0c;读取HTTP响应并解析5#xff0c;保存内容到文件并关闭socket连接代码实现如下#xff1a;/** 使用socket获取远程资源(网页…步骤1匹配URL中的主机名和文件部分2创建socket并连接到目标服务器3构造HTTP请求并发送4读取HTTP响应并解析5保存内容到文件并关闭socket连接代码实现如下/** 使用socket获取远程资源(网页图片等)* url 资源URL* savepath 资源的保存路径* return true/false*/function get_remote_picture($url,$savepath./){set_time_limit(0);$pattern /(http:\/\/)?([^\/])(.)/;$res preg_match($pattern, $url, $matches);if($res 0){return false;}$host ;//主机名$file ;//请求的文件if(count($matches) 3){$host $matches[1];$file $matches[2];}else if(count($matches) 4){$host $matches[2];$file $matches[3];}else{return false;}$socket socket_create(AF_INET,SOCK_STREAM,SOL_TCP);$res socket_connect($socket,gethostbyname($host),80);if(!$res){//echo socket_strerror(socket_last_error($socket));socket_close($socket);return false;}$request ;$request . GET $file HTTP/1.1\r\n;$request . Host: $host\r\n;$request . Connection: close\r\n\r\n;$len socket_write($socket,$request);$response ;while($bufsocket_read($socket,512)){if(strlen($buf) 0){break;}$response . $buf;}if(strpos($response,\r\n\r\n)){$arr explode(\r\n\r\n,$response);if(!file_exists($savepath)){mkdir($savepath);}$savepath rtrim($savepath,/)./;file_put_contents($savepath.basename($file),$arr[1]);}else{socket_close($socket);return false;}socket_close($socket);return true;}/* 获取百度logo */$url http://su.bdimg.com/static/superplus/img/logo_white.png;$result get_remote_picture($url);if($result){echo get remote picture success;}else{echo get remote picture failed;}