ASP to realize English online translation

Source: Internet
Author: User

<title> Online Translator </title>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<body>
<%
' On Error Resume Next
' If the speed is slow, you can adjust the following time. Per second
Server.ScriptTimeout = 999999
'========================================================
' Character encoding function
'========================================================
Function Bytestobstr (Body,code)
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 =code
Bytestobstr = objstream. ReadText
Objstream. Close
Set objstream = Nothing
End Function
The position in another string where the ' fetch ' string appears
Function newstring (WSTR,STRNG)
Newstring=instr (LCase (WSTR), LCase (STRNG))
If Newstring<=0 then Newstring=len (WSTR)
End Function
' Replace string function
function Replacestr (ORI,STR1,STR2)
Replacestr=replace (ORI,STR1,STR2)
End Function
'=====================================================
function ReadXml (url,code,start,ends)
Set Osend=createobject ("Microsoft.XMLHTTP")
SourceCode = Osend.open ("Get", Url,false)
Osend.send ()
Readxml=bytestobstr (Osend.responsebody,code)
if (start= "" or ends= "") Then
Else
Start=newstring (Readxml,start)
Readxml=mid (Readxml,start)
Ends=newstring (Readxml,ends)
Readxml=left (readxml,ends-1)
End If
End Function
Dim Urlpage,lan
Urlpage=request ("URLs")
Lan=request ("LAN")
%>
<form method= "POST" action= "translate.asp" >
<input type= "text" name= "URLs" size= "value=" "<%=urlpage%>" >
<input type= "hidden" name= "LAN" value= "<%=lan%>" >
<input type= "Submit" value= "Submit" >
</form>
<%
Dim Transurl
Transurl= "Http://216.239.39.104/translate_c?hl=zh-CN&ie=UTF-8&oe=UTF-8&langpair=" &server. UrlEncode (LAN) & "&u=" &urlpage& "&prev=/language_tools"
if (Len (urlpage) >3) Then
Getcont=readxml (Transurl, "gb2312", "", "")
Response. Write (Getcont)
End If
%>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.