只剩57分了 到时有分全加上<?php
ob_start();
session_start();
$url = "http://zh.wikipedia.org/w/index.php?title=%E9%83%A7%E8%A5%BF%E5%8E%BF&variant=zh-cn";
$preg="#<p>(.*)</p>#iUs";
readfile($url);
$img = ob_get_contents();
preg_match_all($preg,$img,$arry);
ob_end_clean();
foreach($arry[0] as $id=>$name)
{
echo $name."</br>";
}
//$str = urldecode('%E9%83%A7%E8%A5%BF%E5%8E%BF');
//echo $str
?>
(1)我的代码已贴上去 我是想通过这个代码抓取WIKI百科文章内容里面的关键字 可是现在有问题,一旦运行后echo输出在网页中就为空白网页 我不知道是哪里有问题 请高手运行我的程序帮忙 看看,(2)顺便可以告诉我如何获取wiki百科中文章的关键字呢?我现在只是获取文章就出现问题 如上两个问题(1)(2)
在线 等
ob_start();
session_start();
$url = "http://zh.wikipedia.org/w/index.php?title=%E9%83%A7%E8%A5%BF%E5%8E%BF&variant=zh-cn";
$preg="#<p>(.*)</p>#iUs";
readfile($url);
$img = ob_get_contents();
preg_match_all($preg,$img,$arry);
ob_end_clean();
foreach($arry[0] as $id=>$name)
{
echo $name."</br>";
}
//$str = urldecode('%E9%83%A7%E8%A5%BF%E5%8E%BF');
//echo $str
?>
(1)我的代码已贴上去 我是想通过这个代码抓取WIKI百科文章内容里面的关键字 可是现在有问题,一旦运行后echo输出在网页中就为空白网页 我不知道是哪里有问题 请高手运行我的程序帮忙 看看,(2)顺便可以告诉我如何获取wiki百科中文章的关键字呢?我现在只是获取文章就出现问题 如上两个问题(1)(2)
在线 等
$url = "http://zh.wikipedia.org/w/index.php?title=%E9%83%A7%E8%A5%BF%E5%8E%BF&variant=zh-cn";
$fp=@fopen($url,”r”) or die (“超时”);
$fContent=file_get_contents($url);
eregi(“<p>(.*.)</p>”,$fCountent,$rg);
foreache($rg as $value)
{
echo $value."<br />";
}
$rows = strip_tags($contents);
$arr = array(' ',' ',"\s", "\r\n", "\n", "\r", "\t", ">", "“", "”");
$qc_rows = str_replace($arr, '', $rows);
if(strlen($qc_rows)>2400){
$qc_rows = substr($qc_rows, '0', '2400');
}
$data = @implode('', file("http://keyword.discuz.com/related_kw.html?title=$contents&ics=gbk&ocs=gbk"));
preg_match_all("/<kw>(.*)A\[(.*)\]\](.*)><\/kw>/",$data, $out, PREG_SET_ORDER);
for($i=0;$i<5;$i++){
$key=$key.$out[$i][2];
if($out[$i][2])$key=$key.",";
}
return $key;
}
详细出处参考:http://www.jb51.net/article/22068.htm
你那里不对,应该是你php设置问题。获取远程网页内容,建议用curl.
没见到那个网页里有什么关键字??