I'm tring to modify TransSynonyms : Set TransSynonyms = Doc.querySelector(".gt-cd.gt-cd-mss")
VBA Code:
Sub Test()
Cells.Clear
ExtractExsamples "en", "ar", "man"
End Sub
Private Sub ExtractExsamples(FromLng, ToLng, StrText)
Dim IE As Object 'New InternetExplorer
Dim Url As String
Dim Doc As Object
Dim clipboard As Object
Dim rel As Object
'Dim Elem As Variant
Dim Synonymsresult As Object
Set IE = CreateObject("InternetExplorer.Application")
Set clipboard = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
Url = "https://translate.google.com/?hl=en&tab=wT&authuser=0#view=home&op=translate&sl=" & FromLng & "&tl=" & ToLng & "&text=" & LCase(StrText)
With IE
.Visible = True
.navigate Url
While IE.ReadyState <> 4
DoEvents
Wend
Application.Wait (Now + TimeValue("0:00:02"))
Set Doc = IE.Document
'
Set TransSynonyms = Doc.querySelector(".gt-cd.gt-cd-mss")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Modify TransSynonyms nodes
For Each listNode In TransSynonyms.ChildNodes
For Each fieldNode In listNode.ChildNodes
Debug.Print "[" & fieldNode.Text & "]"
Next
Next
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set TransResult = Doc.querySelector(".tlid-result.result-dict-wrapper")
SinglReult = TransResult.querySelector(".tlid-translation.translation").outertext
Set ExtenCount = TransSynonyms.querySelector(".cd-expand-button")
On Error Resume Next
Getinnertext = Replace(TransSynonyms.innerText, ExtenCount.innerText, "")
Getinnertext = Replace(Replace(Replace(Getinnertext, Chr(10) & Chr(13), Chr(13)), Chr(13), ""), Chr(10), "", 1, 1)
Getoutertext = TransSynonyms.outertext
Getoutertext = Replace(Replace(Replace(Getoutertext, Chr(10) & Chr(13), Chr(13)), Chr(13), ""), Chr(10), "", 1, 1)
[A1] = Getinnertext ''Range("A1") no Change
[B1] = Getoutertext ''Range("B1") no Change
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'VVVVVVVVVVVVVVVVVVVVVVVVVVVV
' To be Like this
Getinnerhtml = Replace(Replace(Replace(Replace(TransSynonyms.innerHTML, ExtenCount.innerHTML, ""), "</span><span", "</span><span>] [</span><span"), "span""><span", "span""><span>[</span><span"), "</span></span>", "</span><span>]</span></span>")
Getinnerhtml = "<html lang=""en""><head><body>" & Getinnerhtml & "</body></html>"
clipboard.SetText Getinnerhtml
clipboard.PutInClipboard
[A2].PasteSpecial ''Range("A2")
Getouterhtml = Replace(Replace(Replace(Replace(TransSynonyms.outerHTML, ExtenCount.outerHTML, ""), "</span><span", "</span><span>] [</span><span"), "span""><span", "span""><span>[</span><span"), "</span></span>", "</span><span>]</span></span>")
Getouterhtml = "<html lang=""en""><head><body>" & Getouterhtml & "</body></html>"
clipboard.SetText Getouterhtml
clipboard.PutInClipboard
[B2].PasteSpecial 'Range("B2")
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'VVVVVVVVVVVVVVVVVVVVVVVVVVVV
.Quit
End With
End Sub