欢迎访问雨楠喃语官方个人主页!
咨询电话:139-9180-9967
正在浏览:[原创]火车时刻表查询V0.1版(雨楠修改,数据来自百度)
[ASP][原创]火车时刻表查询V0.1版(雨楠修改,数据来自百度)
作者:互联网 | 来源:网络 | 发布:2009/11/25 15:36:58 | 浏览:2125

演示地址:

http://gaozhen.net.cn/test/train.asp

 [复制代码]

<%
On Error Resume Next
function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
set http=nothing
if err.number<>0 then err.Clear
end function
'==================================================
'函数名:GetBody
'作 用:截取字符串
'参 数:ConStr ------将要截取的字符串
'参 数:StartStr ------开始字符串
'参 数:OverStr ------结束字符串
'参 数:IncluL ------是否包含StartStr
'参 数:IncluR ------是否包含OverStr
'==================================================
Function GetBody(ConStr,StartStr,OverStr,IncluL,IncluR)
If ConStr="$False$" or ConStr="" or IsNull(ConStr)=True Or StartStr="" or IsNull(StartStr)=True Or OverStr="" or IsNull(OverStr)=True Then
GetBody="$False$"
Exit Function
End If
Dim ConStrTemp
Dim Start,Over
ConStrTemp=Lcase(ConStr)
StartStr=Lcase(StartStr)
OverStr=Lcase(OverStr)
Start = InStrB(1, ConStrTemp, StartStr, vbBinaryCompare)
'response.write Start&"<br>"&IncluL&"<br>"
'response.end
If Start<=0 then
GetBody="$False$"
Exit Function
Else
If IncluL=False Then
Start=Start+LenB(StartStr)
End If
End If
Over=InStrB(Start,ConStrTemp,OverStr,vbBinaryCompare)
If Over<=0 Or Over<=Start then
GetBody="$False$"
Exit Function
Else
If IncluR=True Then
Over=Over+LenB(OverStr)
End If
End If

GetBody=MidB(ConStr,Start,Over-Start)
End Function
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function

Function mytrian(s1,s2)
Dim url,html,citys
url="http://open.baidu.com/train/search.php?wd=%C1%D0%B3%B5%CA%B1%BF%CC%B1%ED&act=station&s1="&s1&"&s2="&s2&""
html=getHTTPPage(url)
citys=getBody(html,"提供</caption>","</div>",false,false)
If citys = "$False$" Then
citys = "<font size=2>没有结果,请重新输入您要查询的两站名称.</font>"
End If
response.write ""&citys&""
End Function


Function mytriancc(s3)
Dim url,html,cityss
url="http://open.baidu.com/train/search.php?wd=%C1%D0%B3%B5%CA%B1%BF%CC%B1%ED&act=train&s3="&s3&""
html=getHTTPPage(url)
cityss=getBody(html,"提供</caption>","</div>",false,false)
If cityss = "$False$" Then
cityss = "<font size=2>没有结果,请重新请输入您要查询的车次.</font>"
End If
response.write ""&cityss&""
End Function

%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>列车时刻表-雨楠修改版(来自百度数据库)</title>
<style>
Td{font-size:13px;}
.input160{width:160px;height:22px;font-size:12px;color:#008DDD;background:#FAFAFA;border:1px solid #8899AE;}
.input80{width:80px;height:22px;font-size:12px;color:#008DDD;background:#FAFAFA;border:1px solid #8899AE;}
.subbb{height:22px;font-size:12px;color:#1C6DD1;background:#EEEEEE;border:1px solid #8899AE;}
.menubt1{font-size:14px;color:#008DDD;font-weight:bold;text-align:center;background:#DFF2FA;height:30px;}
.menubt2{font-size:13px;color:#008DDD;text-align:center;background:#DEEDF3;height:25px;}
</style>
<style>
#train_info {font-size:12px;font-family:arial;}
#from_to {font-size:14px;font-weight:bold;padding-right:30px;}
#time {padding-right:30px;}
#stations {border-collapse:collapse;border:1px solid #e8e8e8;width:95%;max-width:960px}
#stations caption {font-size:12px;padding-bottom:10px;text-align:right;}
#stations caption img {margin-bottom:-5px;}
#stations th, #stations td {border:1px solid #E8E8E8;}
#stations th {background:#F2F2F2;font-size:13px;padding:8px 12px;font-weight:normal;}
#stations td {font-size:12px;padding:7px;text-align:center;}
#stations tr.color {background:#F6F6F6;}
</style>
<%
Dim s1,s2,s3
s1 = request("s1")
s2 = request("s2")
s3 = request("s3")
%>
</head>
<body bgcolor="#EEFAFF" topmargin="2" leftmargin="2" rightmargin="0" bottommargin="2">
<table border="0" width="100%" cellspacing="1">
<tr>
<td class="menubt1">
火车时刻表查询V0.1版</td>
</tr>
<tr><form action="" target="_self">
<td class="menubt2">
出发城市:<input id="s1" class="input80" name="s1" type="text" value="<%=s1%>" maxlength="100" size="1">
到达城市:<input id="s2" class="input80" name="s2" type="text" value="<%=s2%>" maxlength="100" size="1">
<input name="zzzz" class="subbb" type=submit value="站站查询">
</td></form>
</tr>
<tr><form action="" target="_self">
<td class="menubt2">
输入车次:<input id="s3" class="input160" name="s3" type="text" value="<%=s3%>" maxlength="100" size="1">
<input name="csss" type=submit class="subbb" value="车次查询(如T140)">
</td></form>
</tr>
</table>
<div id="train_info"></div>
<div id="station_info">
<table cellpadding="0" cellspacing="0" class="ti" id="stations">
<tbody>
<%Call mytrian(""&s1&"",""&s2&"")%></div>




<div id="train_info"></div>
<div id="station_info">
<table cellpadding="0" cellspacing="0" class="ti" id="stations">
<tbody>
<%Call mytriancc(""&s3&"")%></div>


<table border="0" width="100%" cellspacing="1">
<tr><form action="" target="_self">
<td class="menubt2">
出发城市:<input id="s1" class="input80" name="s1" type="text" value="<%=s1%>" maxlength="100" size="1">
到达城市:<input id="s2" class="input80" name="s2" type="text" value="<%=s2%>" maxlength="100" size="1">
输入车次:<input id="s2" class="input80" name="s3" type="text" value="<%=s3%>" maxlength="100" size="1">
<input name="zzzz" class="subbb" type=submit value="同时查询">
</td></form>
</tr>
<tr>
<td class="menubt2">本站火车时刻表来自百度,更多信息请查阅www.baidu.com</td>
</tr>
</table>
</body></html>


相关ASP