header("Content-type: text/html; charset=utf-8");
if(!empty($_POST['input_text'])) {
$data = file_get_contents( $_POST['input_text'] );
$charset_pos = stripos($data,'charset');
if($charset_pos) {
if(stripos($data,'utf-8',$charset_pos)) {
echo iconv('utf-8','utf-8',$data);
}else if(stripos($data,'gb2312',$charset_pos)) {
echo iconv('gb2312','utf-8',$data);
}else if(stripos($data,'gbk',$charset_pos)) {
echo iconv('gbk','utf-8',$data);
}
return;
}
echo $data;
}else {
?>
$wd = $_GET['wd']; // 获取页面提交来的GET参数
$content = fetch_get_contents(" http://www.baidu.com/s?wd=".$wd); // 根据提交来的GET参数采集百度相关页面
echo $content; // 输出
?>
最简单的版本,form表单用get来提交,文本框name值是wd,可以自己改
说得偶不是很明白,能实施清楚点吗?