Send ( ) $g_sData = StringRegExpReplace ( $g_oHTTP. Open ( "POST", $g_Url, False ) $g_oHTTP. Global $g_sMytext, $g_sFrom, $g_sTo, $g_Url, $g_oHTTP, $g_sData $g_sMytext = "This is an English text to be translated into Italian." $g_sFrom = "en" $g_sTo = "it" $g_Url = "" & $g_sFrom & "&tl=" & $g_sTo & "&dt=t&q=" & $g_sMytext $g_oHTTP = ObjCreate ( "Microsoft.XMLHTTP" ) $g_oHTTP. > Result (ital.) : Questo รจ un testo inglese da tradurre in italiano. Example : -> Source (engl.) : This is an English text to be translated into Italian. However, the regular expression still needs some fine-tuning. Some time ago, I created a Q&D code snippet that uses the Microsoft.XMLHTTP object. ![]() getAttribute ( $Attribute ), $AttributeValue ) > 0 Then $GetObj = $aTag ExitLoop EndIf EndIf Next If $GetObj = "" Then Else Return $GetObj EndIf EndFunc =>GetObj ![]() classname, $AttributeValue ) > 0 Then $GetObj = $aTag MsgBox("","","found" & $aTag.innerText) ExitLoop EndIf Else If StringInStr ( $aTag. innerText, $AttributeValue ) > 0 Then $GetObj = $aTag ExitLoop EndIf ElseIf StringLower ( $Attribute ) = "class" Or StringLower ( $Attribute ) = "classname" Then If StringInStr ( $aTag. quit Return $TranslateFromGGL EndFunc Func GetObj ( $Tag, $Attribute, $AttributeValue, $oIE = $oIE ) $aTags = _IETagNameGetCollection ( $oIE, $Tag ) For $aTag In $aTags If StringLower ( $Attribute ) = "innertext" Then If StringInStr ( $aTag. innerText If Then $TranslateFromGGL = "It was not able to trasnlate your request!" Else $TranslateFromGGL = $html EndIf $oIE. quit $TranslateFromGGL = "It was not able to translate your request" Exit EndIf Local $html = $oTranslated. Expand collapse popup #include $translateText = clipget ( ) $textResault = TranslateFromGGL ( $translateText, "bg" ) ConsoleWrite ( $textResault ) Func TranslateFromGGL ( $sTextToTranslate, $ToLanguageCode ) $URL = "" & $ToLanguageCode & "&text=" & $sTextToTranslate Global $oIE = _IECreate ( $URL, 0, 0, 1 ) $oTranslated = GetObj ( "span", "class", "tlid-translation translation", $oIE ) If Then $oIE.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |