我有这个脚本,它需要生成的是一个不是一个好主意,我想改变生成的。如果有人可以帮助我如何做法划线,我会欣赏。

$SH = fsockopen($IP, $Port, $errno, $errstr, 30);
echo $errstr;    
#$ch = curl_init();
#curl_setopt($ch, CURLOPT_TIMEOUT, 30);
#curl_setopt($ch, CURLOPT_URL, $IP.":".$Port);
#curl_setopt ($ch, CURLOPT_HEADER, 0);
    if ($SH){ 
        fputs($SH,"GET /7.html HTTP/1.0\r\nUser-Agent: S_Status (Mozilla Compatible)\r\n\r\n");
        $content = "";
        while(!feof($SH)) { 
            $content .= fgets($SH, 1000);
            #content .= curl_setopt($ch, CURLOPT_FILE, $SH);
        }
        fclose($SH);
        #curl_close($ch);
}
.

有帮助吗?

解决方案

If I understand your question correctly, you're just looking for how to send the HTTP request (that's what your fputs($SH, "GET ...") is doing, that is done using curl_exec(). Seems like this should work.

$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_PORT, $Port);
curl_setopt($ch, CURLOPT_URL, $IP . '/7.html');
curl_setopt($ch, CURLOPT_USERAGENT, 'S_Status (Mozilla Compatible)'); 
//tell curl to return the output, not display it
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
//execute the request
$content = curl_exec($ch);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top