获取页面内容的一个函数
- function getwebdate($url){
- $tmp = str_replace('http://', '', $url);
- $domain = substr($tmp, 0, strpos($tmp, '/'));
- $path = strstr($tmp, '/');
- $fp = fsockopen($domain, 80, $errno, $errstr, 30);
- if (!$fp) {
- echo "$errstr ($errno)
n";
- } else {
- $out = "GET $path HTTP/1.1rn";
- $out .= "Host: {$domain}rn";
- //$out .= "Referer: {$url}rn";
- $out .= "Connection: Closernrn";
-
- fwrite($fp, $out);
- while (!feof($fp)) {
- $html .= fgets($fp, 128);
- }
- fclose($fp);
- return substr(strstr($html, "rnrn"), 4);
- }
- }
复制代码
|