有关fopen及相关问题,急等回复! $temp=explode("<td>", $testphp);$temp=explode("</td>", $temp[1]);echo $temp[0]; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 谢谢你!举个例子,如果想提取http://www.iciba.net/dictionary/search.asp?inputword=hello里面的翻译呢?我试了几次都没成功呢? <?php$handle = fopen ("http://www.iciba.net/dictionary/search.asp?inputword=hello", "r");while (!feof ($handle)) { $buffer = fgets($handle);echo $buffer;}fclose ($handle);?>这样就可以了,你试试看我这里已经取到了 是啊,谢谢你 nethermit(网络隐士) 但我试了几次都没成功啊!我是新手,望指教一二!<?php$handle = fopen ("http://www.iciba.net/dictionary/search.asp?inputword=hello", "r");while (!feof ($handle)) { $buffer = fgets($handle,1024); $temp=explode("<span id=\"lbExplain\">", $buffer);$temp=explode("</span>", $temp[1]);echo $temp[0];##############################################################################################################################################// echo $buffer;}fclose ($handle);?> 这就是了,恭喜恭喜,你悟道了!如果你的$buffer没用的话,$temp也不需要开,直接$buffer = fgets($handle,1024);$buffer = explode("<span id=\"lbExplain\">", $buffer);$buffer = explode("</span>", $buffer[1]);节约一个变量 你没有成功是因为你用了$buffer推荐你用file_get_contents函数程序这样写<?$buffer = file_get_contents("http://www.iciba.net/dictionary/search.asp?inputword=hello");$buffer = explode("<span id=\"lbExplain\">", $buffer);$buffer = explode("</span>", $buffer[1]);echo $buffer[0];?> 你用的PHP版本是多少?file_get_contents需要4.3.0以上 搞不懂你干什么不自己分析一下页面,用这个肯定可以,关掉防火墙<?$buffer = file_get_contents("http://www.iciba.net/dictionary/search.asp?inputword=hello");$buffer = explode("<body>", $buffer);$buffer = explode("</body>", $buffer[1]);echo $buffer[0];?> 呵呵,这就是高手与新手的差别,我分析了半天了,但不明白explode的作用,看了文档,还是似懂非懂的!谢谢你了! PHP,我想用正则表达式得到数组(@中肖,@尖,@地s_3法,@在有)这四个数组元素,不包含@空格。 关于php调用shell脚本,脚本中部分命令不执行的问题 php页面中,404设置 有没有一起学WEB开发的QQ群呀? mysql 线程问题,请教大侠们,顶者有分! 这一语句哪有问题?着急啊 mysql占用CPU超过50%,有什么办法优化 关于一个函数引用问题,帮忙!!! 无法结束session,各位请帮忙,谢谢 html/js 怎么调用PHP文件 如何删除数组中的指定数值? 在mysql中怎么取得数据长度为定长的记录集?
$handle = fopen ("http://www.iciba.net/dictionary/search.asp?inputword=hello", "r");
while (!feof ($handle)) {
$buffer = fgets($handle);
echo $buffer;
}
fclose ($handle);
?>
这样就可以了,你试试看
我这里已经取到了
<?php
$handle = fopen ("http://www.iciba.net/dictionary/search.asp?inputword=hello", "r");
while (!feof ($handle)) {
$buffer = fgets($handle,1024);
$temp=explode("<span id=\"lbExplain\">", $buffer);
$temp=explode("</span>", $temp[1]);
echo $temp[0];
#######################################################################
#######################################################################
// echo $buffer;
}fclose ($handle);?>
如果你的$buffer没用的话,$temp也不需要开,直接
$buffer = fgets($handle,1024);
$buffer = explode("<span id=\"lbExplain\">", $buffer);
$buffer = explode("</span>", $buffer[1]);
节约一个变量
程序这样写
<?
$buffer = file_get_contents("http://www.iciba.net/dictionary/search.asp?inputword=hello");
$buffer = explode("<span id=\"lbExplain\">", $buffer);
$buffer = explode("</span>", $buffer[1]);
echo $buffer[0];
?>
file_get_contents需要4.3.0以上
<?
$buffer = file_get_contents("http://www.iciba.net/dictionary/search.asp?inputword=hello");
$buffer = explode("<body>", $buffer);
$buffer = explode("</body>", $buffer[1]);
echo $buffer[0];
?>