可以的啊,这是手册上的例子例子 21-1. 获取远程文件的标题<?php $file = fopen ("http://www.example.com/", "r"); if (!$file) { echo "<p>Unable to open remote file.\n"; exit; } while (!feof ($file)) { $line = fgets ($file, 1024); /* This only works if the title and its tags are on one line */ if (eregi ("<title>(.*)</title>", $line, $out)) { $title = $out[1]; break; } } fclose($file); ?>
小邪,我用你的程序打开我那个加密的https地址,提示说: Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/lanssoft/public_html/smith/test2.php on line 4Warning: fsockopen(): unable to connect to https://ssl.clickbank.net/z/cbank/1.cgi?ii=34313234343665616e627130676e377a2e302e64616e69656c2e3032372e31323935&s=&&er=F&ct=m&cm=05&cb=&c1=&c2=&cy=2006&cn=5324289831537011&cv=232&nn=ZSDF_A&[email protected]&ic=CN&zc=323323&t=Gibbleguts_Screensaver_Pack&c=yxztx87z&js=1:443 in /home/lanssoft/public_html/smith/test2.php on line 4 Permission denied (13)
$file = fopen ("http://www.example.com/", "r");
if (!$file) {
echo "<p>Unable to open remote file.\n";
exit;
}
while (!feof ($file)) {
$line = fgets ($file, 1024);
/* This only works if the title and its tags are on one line */
if (eregi ("<title>(.*)</title>", $line, $out)) {
$title = $out[1];
break;
}
}
fclose($file);
?>
发贴基本上都是问题。唉。dcross(叉叉) :我知道,fopen但是没法打开https的地址来获取内容啊。
尤其是对方的网址是https的时候。注:可以使用url变量的形式来提交。
$fp = fsockopen("www.aspeasy.com", 443, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.aspeasy.com\r\n";
$out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
不使用协议,可以使用现成控件可以实现
思路如下
在网页中插入一个ie控件(或拿这个控件再开发另一个控件),使用这个控件来获取https网页,再把这个网页内容,放到一个变量中,提交到另一个页,到那个页再处理这个https页
最好不要使用那些控件,弹那些东西在一些比较小的网站上,没大有必要。
需要怎么分析协议?是不是用来得到字符串用的?
Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/lanssoft/public_html/smith/test2.php on line 4Warning: fsockopen(): unable to connect to https://ssl.clickbank.net/z/cbank/1.cgi?ii=34313234343665616e627130676e377a2e302e64616e69656c2e3032372e31323935&s=&&er=F&ct=m&cm=05&cb=&c1=&c2=&cy=2006&cn=5324289831537011&cv=232&nn=ZSDF_A&[email protected]&ic=CN&zc=323323&t=Gibbleguts_Screensaver_Pack&c=yxztx87z&js=1:443 in /home/lanssoft/public_html/smith/test2.php on line 4
Permission denied (13)
你看,PHP版面的人有多么热心
你每次1分,两分的都这么多人抢着回答!
研究研究去了
在curl_exec($ch)之前加一项设置
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
就不会把结果显示出来了,你可以用$result=curl_exec($ch),去读$result的结果
curl_setopt($ch, CURLOPT_POSTFIELDS, "Data1=blah&Data2=blah");
这样的含义是不是等同于
curl_setopt($ch, CURLOPT_URL, $url?Data1=blah&Data2=blah);
?
curl_setopt($ch, CURLOPT_URL, $url);
//只能是$url只能是不带参数的http地址,如$url="http://www.gotogame.com.cn";
curl_setopt($ch, CURLOPT_POST, 1);//用post还是get方式传递参数;
curl_setopt($ch, CURLOPT_POSTFIELDS, "Data1=blah&Data2=blah");//传递参数
curl_exec($ch);//执行操作
curl_close($ch);//关闭资源