- ©«¤l
- 2035
- ¥DÃD
- 24
- ºëµØ
- 0
- ¿n¤À
- 2031
- ÂI¦W
- 0
- §@·~¨t²Î
- Win7
- ³nÅ骩¥»
- Office2010
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2012-3-22
- ³Ì«áµn¿ý
- 2024-2-1
|
¦^´_ 8# brianhau - Option Explicit
- Private oxmlhttp As Object
- Private ohtml As Object
- Sub Ex()
- Dim txt As String
-
- ' txt = dictionary_oxford("simulation")
- ' MsgBox "simulation = " & txt
- ' searchITA ([A1])
- searchIT ([A1])
- End Sub
- Function dictionary_oxford(word As String)
- Dim colNodes As Object, bFound As Boolean, x As Variant
-
- If oxmlhttp Is Nothing Then Set oxmlhttp = CreateObject("msxml2.xmlhttp")
- If ohtml Is Nothing Then Set ohtml = CreateObject("htmlfile")
-
- With oxmlhttp
- .Open "get", "http://www.oxfordlearnersdictionaries.com/definition/english/" & word, False
- .send
- ohtml.body.innerhtml = .responseText
-
- ' <span class="def" ...
- Set colNodes = ohtml.getElementsByTagName("span")
- For Each x In colNodes
- If x.className = "def" Then bFound = True: dictionary_oxford = x.innerText: Exit For
- Next
- If Not bFound Then dictionary_oxford = "# Not Found #"
- End With
- End Function
- Function searchIT(rng As Range)
- Dim XH As Object, shpRm As Shape
- Dim iurl, iurl2 As String
-
- Columns("B:B").Select
- With Selection.Font
- .Name = "Arial Unicode MS"
- .Size = 12
- End With
-
- Range("B:J").Clear
- ' Range("a1").Select
- rng.Select
- ' ²M°£¤w¦³ªº¸ÑÄÀ¤Îµ¼Ð
- iurl = "http://tw.dictionary.search.yahoo.com/search?p="
- iurl2 = "http://dict.tw/index.pl?query="
- For Each rng In ActiveSheet.Range("a1", ActiveSheet.Range("A" & Rows.Count).End(xlUp))
- rng.Select
- If rng.Value <> "" Then
- rng.Select
- Set XH = CreateObject("Microsoft.XMLHTTP")
- With XH
- .Open "get", iurl & rng, False
- .send
- ' On Error Resume Next
- ' ±qYahoo¦r¨åºK¨ú²Ä¤@²Õ¤¤¤å½Ķ
- ' rng.Offset(0, 20) = .responseText
- rng.Offset(0, 20) = ""
- If InStr(.responseText, "><h4>1.") > 0 Then rng.Offset(0, 2) = Trim(Split(Split(.responseText, "><h4>1.")(1), "<")(0))
- ' ºK¨úKKµ¼Ð
- If InStr(.responseText, ">KK[") > 0 Then rng.Offset(0, 1) = "[" & Split(Split(.responseText, ">KK[")(1), "]")(0) & "]"
- .Open "get", iurl2 & rng, False
- .send
- ' ±qDICT.TW ^º~¦r¨åÂ^¨ú¦r¸q
- If InStr(.responseText, "</span><br /> ") > 0 Then rng.Offset(0, 3) = Split(Split(.responseText, "</span><br /> ")(1), "<")(0)
- End With
- rng.Offset(0, 9) = dictionary_oxford(rng.Value)
- End If
- Next
- End Function
- Function searchITA(rng As Range)
- Dim XH As Object, shpRm As Shape
- Dim iurl, iurl2 As String, x As Variant
- Dim colNodes As Object, bFound As Boolean, oxford As String
-
- Columns("B:B").Select
- With Selection.Font
- .Name = "Arial Unicode MS"
- .Size = 12
- End With
- ' ²M°£¤w¦³ªº¸ÑÄÀ¤Îµ¼Ð
- Range("B:J").Clear
- ' Range("a1").Select
- rng.Select
-
- iurl = "http://tw.dictionary.search.yahoo.com/search?p="
- iurl2 = "http://dict.tw/index.pl?query="
- For Each rng In ActiveSheet.Range("a1", ActiveSheet.Range("A" & Rows.Count).End(xlUp))
- rng.Select
- If rng.Value <> "" Then
- rng.Select
- Set XH = CreateObject("Microsoft.XMLHTTP")
- With XH
- .Open "get", iurl & rng, False
- .send
- ' On Error Resume Next
- ' ±qYahoo¦r¨åºK¨ú²Ä¤@²Õ¤¤¤å½Ķ
- If InStr(.responseText, "><h4>1.") > 0 Then rng.Offset(0, 2) = Trim(Split(Split(.responseText, "><h4>1.")(1), "<")(0))
- ' ºK¨úKKµ¼Ð
- If InStr(.responseText, ">KK[") > 0 Then rng.Offset(0, 1) = "[" & Split(Split(.responseText, ">KK[")(1), "]")(0) & "]"
- .Open "get", iurl2 & rng, False
- .send
- ' ±q DICT.TW ^º~¦r¨åÂ^¨ú¦r¸q
- If InStr(.responseText, "</span><br /> ") > 0 Then rng.Offset(0, 3) = Split(Split(.responseText, "</span><br /> ")(1), "<")(0)
- End With
- If oxmlhttp Is Nothing Then Set oxmlhttp = CreateObject("msxml2.xmlhttp")
- If ohtml Is Nothing Then Set ohtml = CreateObject("htmlfile")
-
- With oxmlhttp
- .Open "get", "http://www.oxfordlearnersdictionaries.com/definition/english/" & rng, False
- .send
- ohtml.body.innerhtml = .responseText
-
- ' <span class="def" ...
- Set colNodes = ohtml.getElementsByTagName("span")
- For Each x In colNodes
- If x.className = "def" Then bFound = True: oxford = x.innerText: Exit For
- Next
- If Not bFound Then oxford = "# Not Found #"
- End With
- rng.Offset(0, 9) = oxford
- End If
- Next
- End Function
½Æ»s¥N½X |
|