日期:2014-05-18  浏览次数:20420 次

asp利用google实现在线翻译怎么不行啊
如题、、、、
 不知道大家有用过没有。。高了几个小时了,就是不行,纠结啊。。
 我的代码:
 lan.html
 
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>测试</title>
</head>

<body>
你好.我是要翻译的
<form>
<select name="lan">
 <option value="en|de">英语翻译成德语</option>
 <option value="en|es">英语翻译成西班牙语</option>
 <option value="en|fr">英语翻译成法语</option>
 <option value="en|it">英语翻译成意大利语</option>
 <option value="en|pt">英语翻译成葡萄牙语</option>
 <option value="en|ja">英语翻译成日语BETA</option>
 <option value="en|ko">英语翻译成朝鲜语BETA</option>
 <option value="en|zh-CN">英语翻译成中文(简体)BETA</option>
 <option value="de|en">德语翻译成英语</option>
 <option value="de|fr">德语翻译成法语</option>
 <option value="es|en">西班牙语翻译成英语</option>
 <option value="fr|en">法语翻译成英语</option>
 <option value="fr|de">法语翻译成德语</option>
 <option value="it|en">意大利语翻译成英语</option>
 <option value="pt|en">葡萄牙语翻译成英语</option>
 <option value="ja|en">日语翻译成英语BETA</option>
 <option value="ko|en">朝鲜语翻译成英语BETA</option>
 <option value="zh-CN|en">中文(简体)翻译成英语BETA</option>
<input style="FONT-SIZE:12px"type="button"value="Go-&gt;"name="Button1"onClick="javascript:window.open('translate.asp?urls='+document.location+'&lan='+lan.value,'_self','')">
</select>
</form>
</body>
</html>




translate.asp
HTML code
 <html >
<head>
<title>在线翻译</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>

<body>
<%
'on error resume next
' 如果网速很慢的话,可以调整以下时间。单位秒
Server.ScriptTimeout = 999999
'========================================================
'字符编码函数
'========================================================
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 

'取行字符串在另一字符串中的出现位置
Function Newstring(wstr,strng) 
Newstring=Instr(lcase(wstr),lcase(strng)) 
if Newstring<=0 then Newstring=Len(wstr) 
End 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=&quo