
程序代码:
if ( $_SERVER['HTTP_HOST'] )
{
$opts = array(
"http" => array( "method" => "GET", header( "content-Type=text/html;charset=gb2312" ) )
);
$context = stream_context_create( $opts );
header( "content-Type=text/html;charset=gb2312" );
$q = $_GET['q'];
//$pg = $_GET['pg'];
$ct=$_GET['ct'];
$rn=$_GET['rn'];
$pn=$_GET['pn'];
$db=$_GET['db'];
$s=$_GET['s'];
$fbl=$_GET['fbl'];
$s = urlencode( $q );
$title = $q;
$url = "http://video.baidu.com/v?word=".$q."&ct=".$ct."&rn=".$rn."&pn=".$pn."&db=".$db."&s=".$s."&fbl=".$fbl;
$start = "<div id=\"result\">";
$findtemp="<div style=\"background:#eff2fa;padding:10px;\" id=\"rlinks\">";
$temp = file_get_contents( $url, false, $context ); //取出页面信息
$postemp = strpos($temp, $findtemp);
if ($postemp === false) {
$end = "<font>下一页</font></a>";
}else{
$end = "</tr></table></td></tr></table></div>";
}
$endjavascript=intercept_str( $temp, "</body>", "</HTML>", 1 );
$endjavascript=str_replace( "src=sug.js?", "src=http://video.baidu.com/sug.js?", $endjavascript );
$shipinnum=intercept_str( $temp, "百度一下,找到相关视频", "个,用时", 1 ); //取出信息搜索出来的条数
$content = intercept_str( $temp, $start, $end, 0 );
$content = str_replace( "href=\"/v?", "href=\"video.php?", $content );
$content = str_replace( "&word=", "&q=", $content );
$content = str_replace( "href=\"http://video.baidu.com/v?", "href=\"video.php?q=", $content );
if (strlen($content)<'100'){
$content='<div style="text-align:center;margin:20px">搜索失败!<br />搜索超时或者您查询的内容可能不符合相关法律法规和政策,搜索结果未予显示。</div>';
}
这是一段读取截取的代码,有两个函数没有贴出来,这样读取出来的图片连接地址是:http://t1.baidu.com/it/u=627161917,3383339288&fm=20 单独打开能显示,在网页上面就部能显示。
[
本帖最后由 soso51com 于 2010-5-26 11:17 编辑 ]