Connexion à Translate de Google pour traduction
Bonjour,
J'avais fais en VBA sous Excel un traducteur de texte qui se connectait au serveur Translate de Google, ça marchait bien avant mais depuis ça ne marche plus.
il se peut que la connexion ne soit plus gratuite, qu'en pensez vous ?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| Function Translate(RQ As Object, Html As Object, texte As String, Lang_Source As String, Lang_Cible As String) As String
Dim URL As String
Dim elem As Object
'UTF8_Encode (texte)
URL = "https://translate.google.pl/m?&sl=" & Lang_Source & "&tl=" & Lang_Cible & "&ie=UTF-8&prev=_m&q=" & UTF8_Encode(texte)
RQ.Open "POST", URL, False
RQ.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
RQ.send
Html.body.innerHTML = RQ.responseText
Translate_new = Replace(RQ.responseText, "<>", ">" & vbCrLf & "<")
For Each elem In Html.all
If elem.tagName = "DIV" And elem.className = "t0" Then
Translate_new = elem.innerHTML
Exit For
End If
Next elem
End Function |