分享ASP实现的汇率转换,给的是一种思想而已

Code:
  1. <!--#include file="checked.asp"-->    
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
  3. <html xmlns="http://www.w3.org/1999/xhtml">   
  4. <head>   
  5. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />   
  6. <title>无标题文档</title>   
  7. <style>   
  8. div{   
  9. float:left;   
  10. width:600px;   
  11. border: 1px #009933 solid;   
  12. border-bottom:none;   
  13. border-right:none;   
  14. }   
  15. ul{   
  16. width:600px;   
  17. list-style:none;   
  18. height:20px;   
  19. margin:0px;   
  20. padding:0px;   
  21.   
  22. }   
  23. li{   
  24. margin:0px;   
  25. padding:0px;   
  26. width:199px;   
  27. float:left;   
  28. text-align:center;   
  29. border-bottom:1px #009933 solid;   
  30. border-right:1px #009933 solid;   
  31. }   
  32. </style>   
  33. </head>   
  34.   
  35. <body>   
  36. <form action="index.asp" method="post" target=_top>   
  37. <select id=from οnmοuseοver=this.focus(); style="width:200px;background-color:#e9f8d7" size=1 name=from>   
  38.         <option value=CNY>人民币 Chinese Yuan Renminbi . CNY</option>   
  39.         <option value=HKD>港元 Hong Kong Dollar . HKD</option>   
  40.         <option value=TWD>台币 Taiwan Dollar . TWD</option>   
  41.         <option value=EUR>欧元 Euro . EUR</option>   
  42.         <option value=USD>美元 US Dollar . USD</option>   
  43.         <option value=GBP>英镑 British Pound . GBP</option>   
  44.         <option value=AUD>澳元 Australian Dollar . AUD</option>   
  45.         <option value=KRW>韩元 South-Korean Won . KRW</option>   
  46.         <option value=JPY>日元 Japanese Yen . JPY</option>   
  47. </select>   
  48. 兑换   
  49. <select id=to οnmοuseοver=this.focus(); style="width:200px;background-color:#e9f8d7" size=1 name=to>   
  50.         <option value=CNY>人民币 Chinese Yuan Renminbi . CNY</option>   
  51.         <option value=HKD>港元 Hong Kong Dollar . HKD</option>   
  52.         <option value=TWD>台币 Taiwan Dollar . TWD</option>   
  53.         <option value=EUR>欧元 Euro . EUR</option>   
  54.         <option value=USD>美元 US Dollar . USD</option>   
  55.         <option value=GBP>英镑 British Pound . GBP</option>   
  56.         <option value=AUD>澳元 Australian Dollar . AUD</option>   
  57.         <option value=KRW>韩元 South-Korean Won . KRW</option>   
  58.         <option value=JPY>日元 Japanese Yen . JPY</option>   
  59. </select>   
  60. 数额:<input id=q name=q size=10 value="100" οnkeypress="javascript:{if ((event.keyCode > 27 && event.keyCode < 45) || (event.keyCode > 46 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) event.returnValue = false;}">   
  61. <input type=submit value="汇率转换">   
  62. </form>   
  63. <%   
  64. if request.Form("from")<>"" and request.Form("to")<>"" and request.Form("q")<>"" then   
  65. if isnumeric(request.Form("q")) then   
  66. url="http://qq.ip138.com/hl.asp"  
  67. from=request.Form("from")   
  68. tto=request.Form("to")   
  69. q=request.Form("q")   
  70. url=url"?from=" & from & "&to="& tto & "&q="& q   
  71. str=GetHttpPage(url)   
  72. re="<td>(/d+|/d+/./d+)</td><td>(/d+|/d+/./d+)</td><td>(/d+|/d+/./d+)</td>"  
  73. arr=split(replacetext(str,re,4),",")   
  74. response.write "<div><ul><li>"&changstr(from)"</li><li>当前汇率</li><li>"& changstr(tto)"</li></ul><ul><li>"&arr(0)"</li><li>"&arr(1)"</li><li>"&arr(2)"</li></ul></div>"  
  75. response.write "<br><br><br>"  
  76. response.write q&from"的<font color=red>"&changstr(from)"</font>兑换<font color=red>"&changstr(tto)"</font>为:"&replacetext(str,re,3)&tto   
  77. end if   
  78. end if   
  79. str = "<table  border='1' cellspacing='0' cellpadding='0'> <tr> <td>1</td> <td>2</td><td>3 </td> </tr> <tr> <td>4</td> <td>5</td> <td>6</td> </tr> <tr> <td>7</td> <td>8</td> <td>9</td> </tr> <tr> <td>10</td> <td>11</td> <td>12</td></tr> <tr> <td>13</td> <td>14</td> <td>15</td> </tr> </table>"    
  80. Set objRegExp = New Regexp    
  81. objRegExp.IgnoreCase = True    
  82. objRegExp.Global = True  
  83. objRegExp.Pattern ="<td>(/d+)</td>"  
  84. Set Matches =objRegExp.Execute(str)    
  85. For Each Match in Matches   
  86. TempStr=TempStr&Match","  
  87. Next    
  88. response.write TempStr   
  89.   
  90. %>   
  91. </body>   
  92. </html>  

 

checked.asp:

Code:
  1. <%'==================================================   
  2. '函数名:GetHttpPage   
  3. '作 用:获取网页源码   
  4. '参 数:HttpUrl ------网页地址   
  5. '==================================================   
  6. Function GetHttpPage(HttpUrl)   
  7. If IsNull(HttpUrl)=True or Len(HttpUrl)<18 or HttpUrl=""  Then  
  8. GetHttpPage="请求地址出错"  
  9. Exit Function  
  10. End If  
  11. Dim Http   
  12. Set Http=server.createobject("MSXML2.XMLHTTP")   
  13. Http.open "post",HttpUrl,False  
  14. Http.Send()   
  15. If Http.Readystate<>4 then   
  16. Set Http=Nothing    
  17. GetHttpPage="请求地址出错"  
  18. Exit function   
  19. End if   
  20. GetHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")   
  21. Set Http=Nothing  
  22. If Err.number<>0 then   
  23. Err.Clear   
  24. End If  
  25. End Function  
  26.   
  27. '==================================================   
  28. '函数名:BytesToBstr   
  29. '作 用:将获取的源码转换为中文   
  30. '参 数:Body ------要转换的变量   
  31. '参 数:Cset ------要转换的类型   
  32. '==================================================   
  33. Function BytesToBstr(Body,Cset)   
  34. Dim Objstream   
  35. Set Objstream = Server.CreateObject("adodb.stream")   
  36. objstream.Type = 1   
  37. objstream.Mode =3   
  38. objstream.Open   
  39. objstream.Write body   
  40. objstream.Position = 0   
  41. objstream.Type = 2   
  42. objstream.Charset = Cset   
  43. BytesToBstr = objstream.ReadText    
  44. objstream.Close   
  45. set objstream = nothing   
  46. End Function  
  47. function replacetext(Svalue,re,n)   
  48. Set objRegExp = New Regexp    
  49. objRegExp.IgnoreCase = True    
  50. objRegExp.Global = True  
  51. objRegExp.Pattern =re   
  52. Set Matches =objRegExp.Execute(Svalue)    
  53. Set objRegExp=nothing   
  54. For Each Match in Matches   
  55. if n=1 then   
  56. TempStr=Match.SubMatches(0)   
  57. elseif n=2 then   
  58. TempStr=Match.SubMatches(1)   
  59. elseif n=3 then   
  60. TempStr=Match.SubMatches(2)   
  61. elseif n=4 then   
  62. TempStr=Match.SubMatches(0)","& Match.SubMatches(1)","& Match.SubMatches(2)   
  63. end if   
  64. if TempStr<>"" then exit for   
  65. Next    
  66. replacetext=TempStr   
  67. end function   
  68. function changstr(str)   
  69. if str="HKD" then   
  70. changstr="港元("&str")"  
  71. elseif str="CNY" then   
  72. changstr="人民币("&str")"  
  73. elseif str="TWD" then   
  74. changstr="台币("&str")"  
  75. elseif str="EUR" then   
  76. changstr="欧元("&str")"  
  77. elseif str="USD" then   
  78. changstr="美元("&str")"  
  79. elseif str="GBP" then   
  80. changstr="英镑("&str")"  
  81. elseif str="AUD" then   
  82. changstr="澳元("&str")"  
  83. elseif str="KRW" then   
  84. changstr="韩元("&str")"  
  85. elseif str="JPY" then   
  86. changstr="日元("&str")"  
  87. end if   
  88. end function   
  89. %>   

 

 

评论 29
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一把编程的菜刀

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值