分享到新浪微博 分享到QQ空间 打印

[公告] Poke The BBS招募【长期有效】

我呢,熟悉VB、VB.NET、PHP(至于C就太难了,没学) ID:pmfg UID: 19272(至少UID方便搜索)


<iframe src="http://www.fzwl.tk/so.php" frameborder=“0” scrolling="yes" height="600px" width="1000px"></iframe>

如网页显示不正常,请下载附件中的   /    a.html
so.php是一个我的作品
复制内容到剪贴板
代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>FZ 搜索</title>
<style type="text/css">
*{
  margin:0;
  padding:0;
  font-family:"宋体";
  font-size:9pt;
}
h1{
  font-size:12pt;
}
#main{
  width:900px;
  margin:10px auto;
  text-align:center;
  font-size:12pt;
}
.inp{
  width:400px;
  height:24px;
  line-height:24px;
  border:1px solid #CCCCCC;
  padding:0 5px;
}
.btn{
  width:80px;
  height:28px;
  line-height:28px;
}
.info{
  width:800px;
  border-collapse:collapse;
  margin:10px auto;
}
.info tr{   
  border-collapse:collapse;
}
.info td,.info th{
  border:1px solid #EEA011;
  padding:5px;
}
.trbg{
  background-color:#EC8015;
}
a{
  color:#333333;
  text-decoration:none;
}
a:hover{
  color:#0000FF;
  text-decoration:underline;
}
</style>
</head>
<body>
<?php
if(!empty($_POST['wd'])){
  set_time_limit(0);
  $wd = $_POST['wd'];
  $wd = preg_replace('/[ ]+/',' ',$wd);
  $url = 'http://www.baidu.com/s?wd='.urlencode($wd);
  $s = file_get_contents($url);
  preg_match('/<body[^>]*>([\s\S]*)<\/body>/iU',$s,$d);
  $s = $d[1];
  $arr = array("/\s+/","/\s*<\s*/","/\s*>\s*/","/\s*=\s*/");
  $to = array(' ','<','>','=');
  $s = preg_replace($arr,$to,$s);
  $a = '/<table[^>]*id="\d*"[^>]*>([\s\S]*)<\/table>/iU';
  $a_tit = '/<a[^>]*href="([^"]*)"[^>]*>([\s\S]*)<\/a>/iU';
  $a_intro = '/<font size=(-1|"-1")>([\s\S]*)<br/iU';
  $a_time = '/\d{4}-\d{1,2}-\d{1,2}/';

  preg_match_all($a,$s,$d);
  if(count($d[0])){
   foreach($d[1] as $s){
    preg_match($a_tit,$s,$d);
    $d2['url'] = $d[1];
    $d2['title'] = preg_replace("/<[^>]*>/",'',$d[2]);
    preg_match($a_intro,$s,$d);
    $d2['intro'] = preg_replace("/<[^>]*>/",'',$d[2]);
    preg_match($a_time,$s,$d);
    $d2['time'] = $d[0];
    $RS_data[] = $d2;
   }
   unset($d);
  }
}
?>
<div id="main">
<h1>FZ 搜索</h1>
<form name="frm" action="" method="post" onsubmit="return ckForm(this);">
<table>
<tr>
  <td align="left">请输入搜索词:</td>
</tr>
<tr>
  <td align="right"><input type="text" name="wd" class="inp" onfocus="foc(this);" onblur="blu(this);" value="<?php echo $wd ?>" />&nbsp;&nbsp;<input type="submit" value="搜索" class="btn" /></td>
</tr>
</table>
</form>
<hr />
<table class="info">
<tr>
  <th width="50">排名</th>
  <th width="300">标题</th>
  <th>描述</th>
  <th width="60">收录时间</th>
</tr>
<?php
  if(count($RS_data)){
   $i = 0;
   $s = '';
   foreach($RS_data as $d){
    $i++;
    $s .= '<tr>';
    $s .= "<td>$i</td>";
    $s .= "<td align='left'><a href='$d[url]' target='_blank'>$d[title]</a></td>";
    $s .= "<td align='left'>$d[intro]</td>";
    $s .= "<td>$d[time]</td>";
    $s .= '</tr>';
   }
   echo $s;
  }
?>
</table>
</div>
<script language="javascript" type="text/javascript">
function foc(obj){  
  obj.style.borderColor = '#006BD7';
}

function blu(obj){
  var v = obj.value;
  var color = (v||v=='http://')?'#A5ACB2':'#FF0000';
  obj.style.borderColor = color;
}

function ckForm(f){
  var v = f.wd.value;
  if(v=''){
   alert('请输入搜索词!');
   return false;
  }  
  return true;
}
</script>
</body>
</html>
附件: 您所在的用户组无法下载或查看附件
本帖最近评分记录
  • liuyanghejerry 热度 +1 已了解,等待Youd和你联系吧。 2010-7-18 09:43

TOP