<?php header('Content-Type: text/html; charset=utf-8'); ?>
<form action="" method=post>
<input type="text" name="name" value="">
<input type="submit" value="提交">
</form>
<?php
if(!empty($_POST['name'])){
$url="
http://dict.baidu.com/s?wd=".urlencode($_POST['name']);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,0); //加入重定向处理
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$str=explode("生词本",$output);
$str=explode("帮助",$str[0]);
echo $str[1];
}
?>