日期:2010-12-01  浏览次数:20476 次

 1        Function RemoveHTML()Function RemoveHTML(strhtml)
 2            if strhtml<>"" then
 3                 dim s_str as string
 4                     s_str=regex.replace(strHTML,"<[^>]+>","")
 5                     s_str=replace(s_str," ","")
 6                     return s_str
 7            end if
 8        End Function
 9       
10        Function china_to_english()Function china_to_english(texts,languages)
11            Dim payload As String = "hl=zh-CN&ie=UTF8&text="& texts &"&langpair="& languages &""
12            dim str_return as string 
13            Dim req As WebRequest = WebRequest.Create("http://translate.google.com/translate_t") ' 开始取连接.
14            req.Credentials = CredentialCache.DefaultCredentials       '取得默认
15            req.Method = "POST"                                        '以POST方式发送,这里默认是以GET方式发送
16            req.ContentType = "application/x-www-form-urlencoded"      'POST方式需在传送这个编码,如果上传文件,则修为multipart/form-data
17            req.timeout=10000                                          '连接超时定时
18            req.ContentLength = payload.Length                         '头部长度
19            Dim encoding As Encoding = Encoding.GetEncoding("UTF-8")   '转换成流,大部网站一般转换成UTF-8就可以了,注意是大写的编码
20            Dim bytes As Byte() = Encoding.GetBytes(payload)           '转换成流
21            req.ContentLength = bytes.Length                           '传送流的长度
22            Dim newStream As Stream = req.GetRequestStream()           '转换写入
23            newStream.Write(bytes, 0, bytes.Length)              &nbs