<%
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

%>
