"){ $ch = fgetc($filp); $retval = $retval.$ch; } return $retval; } ?> "; $cnt1= 0; $spaces; $fp = fsockopen ("www.nytimes.com", 80, $errno, $errstr, 30); $fp2 = fopen("./headlines", "w"); //write headlines to a file if (!$fp) { echo "$errstr ($errno)
\n"; } else { fputs ($fp, "GET / HTTP/1.0\r\n\r\n"); while (!feof($fp)) { $str1 = myfget ($fp); if (ereg("", $str1)){ $str2 = ereg_replace("",".",$str1); } else { $str2=""; } $spaces = strlen($str2); if ($spaces == 0){ // echo $cnt1++.", "; } else { //echo $str2; if (strlen($str2) > 40){ while (strlen($str2)<80){ $str2 = $str2." "; } } else { while (strlen($str2)<40){ $str2 = $str2." "; } } echo $str2; fputs($fp2, $str2); } } fclose ($fp); fclose($fp2); } echo "Socket closed."; ?>