|
学习老师的代码。谢谢老师!
Public Function bdfy(tmpWord, y)
Dim s() As String
Dim str_tmp As String, URL
Dim str_base As String
If Len(tmpWord) = 0 Then Exit Function
'开启网页https://fanyi.baidu.com/?#en/zh/aged
With CreateObject("MSXML2.XMLHTTP")
URL = "https://www.baidu.com/s?wd=" & tmpWord & "&ie=UTF-8"
On Error Resume Next
.Open "GET", URL, False
.send (Null)
While .readyState <> 4
DoEvents
Wend
str_base = .responseText
.Close
End With
strtxt = Split(Split(str_base, "</em>_百度翻译</a>")(1), "<div class=""op_dict3_extra"">")(0)
strtxt = Split(strtxt, "</table>")
str1 = Replace(Replace(DelHtml(strtxt(0)), " ", ""), Chr(10), "")
tmpPhonetic = Replace(Mid(str1, Len(tmpWord) + 1, 99), "美[", Chr(10) & "美[")
For i = LBound(strtxt) + 1 To UBound(strtxt) - 1
tt2 = Replace(DelHtml(strtxt(i)), " ", "")
tt2 = Replace(tt2, Chr(10), "")
hytmp = hytmp & vbCrLf & tt2
Next i
bdfy = Choose(y, Mid(hytmp, 2), tmpPhonetic)
End Function
|
评分
-
1
查看全部评分
-
|