首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

站内集成百度,SOHU,GOOGLE搜索功能的源码

2012-01-19 
求一个站内集成百度,SOHU,GOOGLE搜索功能的源码。求一个站内集成百度,SOHU,GOOGLE搜索功能的源码,万分感谢。

求一个站内集成百度,SOHU,GOOGLE搜索功能的源码。
求一个站内集成百度,SOHU,GOOGLE搜索功能的源码,万分感谢。


[解决办法]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<!-- saved from url=(0033)http://www.66162.cn/cityallso.htm -->
<HTML> <HEAD>
<META http-equiv=Content-Type content= "text/html; charset=gb2312 ">
<STYLE type=text/css> .ss {
FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: #fc6b03
}
TD {
FONT-SIZE: 12px
}
.ff {
FONT-SIZE: 12px; COLOR: #ff6600
}
#more {
FONT-SIZE: 12px; COLOR: #008800; TEXT-DECORATION: none
}
#more A {
FONT-SIZE: 12px; COLOR: #008800; TEXT-DECORATION: none
}
#more A:hover {
TEXT-DECORATION: underline
}
A {
FONT-SIZE: 12px; COLOR: #000000; TEXT-DECORATION: none
}
A:visited {
FONT-SIZE: 12px; COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
COLOR: #ff0000; TEXT-DECORATION: underline
}
#tabf {
MARGIN-LEFT: auto; MARGIN-RIGHT: auto
}
</STYLE>
<SCRIPT>
function search4(){if(form1.nsns[3].checked)
window.open( "http://www.iask.com/s?k= "+form1.key.value, "mspg0 ");if(form1.nsns[4].checked)
window.open( "http://www.sogou.com/web?query= "+form1.key.value, "mspg1 ");if(form1.nsns[2].checked)
window.open( "http://www.yahoo.com.cn/search?p= "+form1.key.value, "mspg2 ");if(form1.nsns[12].checked)
window.open( "http://www.skycn.com/search.php?sor=00&ss_name= "+form1.key.value, "mspg3 ");if(form1.nsns[1].checked)
window.open( "http://www.google.cn/search?hl=zh-CN&inlang=zh-CN&ie=GB2312&oe=GB2312&q= "+form1.key.value, "mspg4 ");if(form1.nsns[0].checked)
window.open( "http://www.baidu.com/s?tn=66162com&wd= "+form1.key.value, "mspg0 ");if(form1.nsns[7].checked)
window.open( "http://music.yahoo.com.cn/search?source=66162&pid=66162&p= "+form1.key.value, "mspg7 ");if(form1.nsns[10].checked)
window.open( "http://search2.sogua.com/search/bt_search.asp?search=bt&key= "+form1.key.value, "mspg8 ");if(form1.nsns[8].checked)
window.open( "http://search.qihoo.com/search.html?kw= "+form1.key.value, "mspg9 ");if(form1.nsns[15].checked)
window.open( "http://www.tongcha.com/place/index.asp?search=search+&ip= "+form1.key.value, "mspg18 ");if(form1.nsns[11].checked)
window.open( "http://mp3search.baidu.com/wstsearch?tn=baidump3lyric&ct=150994944&lm=-1&rn=&word= "+form1.key.value, "mspg9 ");if(form1.nsns[13].checked)
window.open( "http://www.baidu.com/baidu?ft=all&q1= "+form1.key.value, "mspg10 ");if(form1.nsns[6].checked)
window.open( "http://image.yahoo.com.cn/search?p= "+form1.key.value, "mspg11 ");if(form1.nsns[14].checked)
window.open( "http://mp3.baidu.com/m?rn=&tn=baidump3&ct=134217728&lm=6&word= "+form1.key.value, "mspg13 ");if(form1.nsns[5].checked)
window.open( "http://news.baidu.com/ns?cl=2&rn=20&tn=news&word= "+form1.key.value, "mspg15 ");if(form1.nsns[9].checked)
window.open( "http://www.iciba.com/search?s= "+form1.key.value, "mspg16 ");if(form1.nsns[16].checked)
window.open( "http://www.imobile.com.cn/simcard.php?simcard= "+form1.key.value, "mspg17 ");return false;} </SCRIPT>

<META content= "MSHTML 6.00.2900.2180 " name=GENERATOR> </HEAD>
<BODY>
<TABLE height=58 cellSpacing=0 width= "100% " borderColorDark=#ffffff cellPadding=0 align=center bgColor=#f6f7f8 borderColorLight=#d3d3d3 >


<FORM name=form1 onsubmit=return(search4())>
<TR>
<TD align=middle width= "34% "> <B> 请输关键字: </B>
<INPUT class=ff size=15
name=key>
<INPUT type=submit value=搜索 name=B2 9pt FONT-SIZE: rgb(0,0,0);> </TD>
<TD width= "66% "> <INPUT type=radio value=0 name=nsns>
<A
href= "http://baidu.com/index.php?tn=66162com "> 百度 </A>
<INPUT
type=radio CHECKED value=google name=nsns>
<A
href= "http://www.google.cn/ "> Google </A>
<INPUT type=radio value=3
name=nsns>
<A href= "http://www.yahoo.com.cn/ "> 雅虎 </A>
<INPUT
type=radio value=1 name=nsns>
<A href= "http://www.iask.com/ "> 爱问 </A>
<INPUT type=radio value=2 name=nsns>
<A
href= "http://www.sogou.com/ "> 搜狗 </A>
<INPUT type=radio
value=baidunews name=nsns>
<A
href= "http://www.66162.cn/newsweek.htm "> 新闻 </A>
<INPUT type=radio
value=yisoupic name=nsns>
<A href= "http://image.yahoo.com.cn/ "> 图片 </A>
<INPUT type=radio value=yisoump3 name=nsns>
<A
href= "http://www.66162.cn/mp3.htm "> MP3 </A>
<INPUT type=radio
value=bbs name=nsns>
<A
href= "http://www.66162.cn/bbs.htm "> 论坛 </A> <BR>
<INPUT type=radio
value=baidudict name=nsns>
<A href= "http://www.iciba.com/ "> 翻译 </A>
<INPUT type=radio value=bt name=nsns>
<A
href= "http://www.66162.cn/bt.htm "> BT电影 </A>
<INPUT type=radio
value=baidump3 name=nsns>
<A
href= "http://www.66162.cn/musicgc.htm "> 歌词 </A>
<INPUT type=radio
value=soft name=nsns>
<A
href= "http://www.66162.cn/software.htm "> 软件 </A>
<INPUT type=radio
value=baidufile name=nsns>
<A href= "http://file.baidu.com/ "> 文档 </A>
<INPUT type=radio value=baiduflash name=nsns>
<A
href= "http://flash.baidu.com/ "> FLASH </A>
<INPUT type=radio value=ip
name=nsns>
<A href= "http://www.66162.cn/tools/ip.htm "> IP地址 </A>
<INPUT
type=radio value=shouji name=nsns>
<A
href= "http://www.66162.cn/tools/shouji.htm "> 手机归属地 </A> </TD>
</TR>
</FORM>
</TABLE>
</BODY> </HTML>

[解决办法]
直接把要的东西抓下来,然后分析后重新排版
namespace aa
{
using System;
using System.Net;
using System.Web;
using System.IO;
using System.Text;

/// <summary>
/// 功能:取得Internet上的URL页的源码
/// </summary>


public class CallWeb
{
#region 私有变量
/// <summary>
/// 网页URL地址
/// </summary>
private string url=null;
/// <summary>
/// 是否使用代码服务器:0 不使用 1 使用代理服务器
/// </summary>
private int proxyState=0;
/// <summary>
/// 代理服务器地址
/// </summary>
private string proxyAddress=null;
/// <summary>
/// 代理服务器端口
/// </summary>
private string proxyPort=null;
/// <summary>
/// 代理服务器用户名
/// </summary>
private string proxyAccount=null;
/// <summary>
/// 代理服务器密码
/// </summary>
private string proxyPassword=null;
/// <summary>
/// 代理服务器域
/// </summary>
private string proxyDomain=null;
#endregion

#region 公共属性
/// <summary>
/// 欲读取的URL地址
/// </summary>
public string Url
{
get{return url;}
set{url=value;}
}
/// <summary>
/// 是否使用代理服务器标志
/// </summary>
public int ProxyState
{
get{return proxyState;}
set{proxyState=value;}
}
/// <summary>
/// 代理服务器地址
/// </summary>
public string ProxyAddress
{
get{return proxyAddress;}
set{proxyAddress=value;}
}
/// <summary>
/// 代理服务器端口
/// </summary>
public string ProxyPort
{
get{return proxyPort;}
set{proxyPort=value;}
}
/// <summary>
/// 代理服务器账号
/// </summary>
public string ProxyAccount
{
get{return proxyAccount;}
set{proxyAccount=value;}
}
/// <summary>
/// 代理服务器密码
/// </summary>
public string ProxyPassword
{
get{return proxyPassword;}
set{proxyPassword=value;}
}
/// <summary>
/// 代理服务器域
/// </summary>
public string ProxyDomain
{
get{return proxyDomain;}
set{proxyDomain=value;}
}

public string Method
{
get { return _Method; }
set { _Method = value; }
}
private string _Method;

public string[] PostData
{
get { return _PostData; }
set { _PostData = value; }
}
private string[] _PostData;

public Encoding MyEncoding
{
get { return _MyEncoding; }
set { _MyEncoding = value; }
}
private Encoding _MyEncoding;


#endregion

#region 公共方法
/// <summary>
/// 读取指定URL地址,存到指定文件中
/// </summary>
public string Get()
{
string ResponseText = String.Empty;
WebRequest request = WebRequest.Create(this.url);
if (Method != null && Method != String.Empty)
{
request.Method = Method;
}

//使用代理服务器的处理
if(this.proxyState==1)
{
//默认读取80端口的数据
if(this.proxyPort==null)
this.ProxyPort= "80 ";

WebProxy myProxy=new WebProxy();
myProxy = (WebProxy)request.Proxy;
myProxy.Address = new Uri(this.ProxyAddress+ ": "+this.ProxyPort);
myProxy.Credentials = new NetworkCredential(this.proxyAccount, this.proxyPassword, this.ProxyDomain);
request.Proxy = myProxy;
}



//请求服务
if (Method == "POST ")
{
string strPostData = String.Empty;
for (int i = 0; i < PostData.Length; i++)
{
strPostData += PostData[i] + "& ";
}
strPostData = strPostData.TrimEnd( '& ');
byte[] bytePostData = MyEncoding.GetBytes( "? " + strPostData);
Stream postStream = request.GetRequestStream();
postStream.Write(bytePostData, 0, bytePostData.Length);
postStream.Close();
}
System.Net.WebResponse response = request.GetResponse();

//返回信息
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream, MyEncoding);
ResponseText = sr.ReadToEnd();
resStream.Close();
sr.Close();

return ResponseText;
}
#endregion

}
}

热点排行