📄 cidian.php
字号:
<?php
header("Content-Type:text/html;charset=gbk");
$word=trim($_POST['word']);
$word = iconv("UTF-8","gbk//TRANSLIT",$word);
if(preg_match( "/[a-zA-Z\-_]+/si", $word )){
echo _Restlt_eng($word);
}else if ( !empty($word) ){
echo _Restlt_chn($word);
}
function _Restlt_chn($date){
$rul="http://www.baidu.com/baidu?ie=gbk&cl=3&ct=1048576&word=$date&tn=downreg";
$contents=@file_get_contents($rul);
preg_match_all("/<span class=\"hanzi\">(.*?)<\/div>/is",$contents,$name);
preg_match_all("/<div class=\"lic\">(.*?)<\/div>/is",$contents,$trans);
if(empty($name[1][0])){
return '未找到和您的关键词 “'.$date.'” 相匹配的词典解释.';
}else{
echo '查询词语:'.$name[1][0];
for($i=0;$i<count($trans[0]);$i++){ echo $trans[0][$i];}
}
}
function _Restlt_eng($date){
$rul="http://www.baidu.com/baidu?ie=gbk&cl=3&ct=1048576&word=$date&tn=downreg";
$contents=@file_get_contents($rul);
$contents=str_replace("src=\"","src=\"http://www.baidu.com/",$contents);
preg_match_all("/<div class=\"wd\">(.*?)<\/div>/is",$contents,$name);
preg_match_all("/<div class=\"explain\">(.*?)<\/div>/is",$contents,$ch_cn);
if(empty($name[1][0])){
return '未找到和您的关键词 “'.$date.'” 相匹配的词典解释.';
}else{
echo $name[1][0].'<br>';
for($i=0;$i<count($ch_cn[0]);$i++){ echo $ch_cn[0][$i];}
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -