Jump to content

Siteden veri çekmek


Aqil990

Recommended Posts

Salam, men azerbaycanliyam bir sorum olacak size şimdi bir siteden veriyi hangi kodla çeke biliriz?

inetgetle sayfanı kaydedib StrinRegExp tag seçmek

bu yoldan başqası yokmu???

yoksa StrinRegExp işleme mekanizmasın anlamadım ben

bilenler nasıl çalışdığını anlata bilirmi???

Link to comment
Share on other sites

tamam diyelimki

su siteden tercuma etdiyi sozu almak istiyorum

Yani

Please register to see this content.
auto|az|work

su rada work yazilan yere ne yazilsa onu tercuma eder ben yukaridaki sayfa acildikda onun tarcumasini

English to Azerbaijani translation — ALPHA

su iş yazisini almak istiyorum

bilmem anlata bildinmi :)

Link to comment
Share on other sites

anladım.sana telefondan yardım ettıgım ıcın tam kod yazamıcam fakat mantık şu sayfaya girer bi metin çevirir kaynak kodlarından string between ile ayırırsın (örnek olarak bnm google resimleri otomatik indiren programın mantığı aynı).Yada bence en iyisi google un apilerini araştırman.

Link to comment
Share on other sites

Ben bir giriş yapım ve kaçim :) Malum sahura kalkacağız.

Inet komutlarına hızlı bir şekilde baktım ve ilgili link ile işe yaramadı. Sonra aklıma ie alt yapsını kullanmak geldi ve işe yaradı!

#include <IE.au3>

Global $Text = "Work" ;Çevirlecek metin
Global $Translate = _Google_Get_Text($Text)
MsgBox(64,"Siteden alınan yazı",$Translate) ;Bu mesaj silinecek. Ilk alınan yazıyı ifade ediyor
; Şimdi bizim için gerekli olan yazıyı bulalım. Bunun için ilk alınan yazının incelenmesi gerekiyor.
Global $FIND_TEXT = _Bl_XML_MID($Translate,"Contribute a better translation:" & @CRLF,@CRLF  & @CRLF)
If @error Then $Translate = _Google_Get_Text($Text) ;Belki ilk alınan yazı hatalıydı. Tekrar linkten yazıyı alalım.
$FIND_TEXT = _Bl_XML_MID($Translate,"Contribute a better translation:" & @CRLF,@CRLF  & @CRLF)
MsgBox(64,"",$FIND_TEXT)

Func _Google_Get_Text($sText, $sFrom = "en", $sTo = "az")
	;http://translate.google.com/?hl=en|#en|az|Text
	Local $Blue_Form = GUICreate("BlueLife Google Translate", 1, 1)
	Local $BLUE_OIE = ObjCreate("Shell.Explorer.2")
	GUICtrlCreateObj($BLUE_OIE, 0, 0, 700, 500)
	$BLUE_OIE.navigate("http://translate.google.com/?hl=en|#" & $sFrom & "|" & $sTo & "|" & $sText) ;Linki açıyoruz.
	_IELoadWait($BLUE_OIE) ;Sayfanın açılmasını bekliyoruz.
	Local $IE_Text = _IEBodyReadText($BLUE_OIE) ;Açılan sayfadaki texti (yazıyı) okuyoruz.
	GUIDelete($Blue_Form) ;Daha önce oluşturduğumuz guiyi siliyoruz.
	Return $IE_Text
EndFunc

Func _Bl_XML_MID($BL_TEXT,$FIRST,$SECOND,$Start = 1)
	Local $BL_RETURN,$INSTR = StringInStr($BL_TEXT,$FIRST,0,$Start)
	If not $INSTR Then Return SetError(1,0,"")
	$BL_RETURN = StringTrimLeft($BL_TEXT,$INSTR + (StringLen($FIRST) -1))
	$INSTR = StringInStr($BL_RETURN,$SECOND)
	If not $INSTR Then Return SetError(1,0,"")
	$BL_RETURN = StringLeft($BL_RETURN,$INSTR -1)
	Return $BL_RETURN
EndFunc

Şuan çok basit bir örnek. Yani geliştirilmesi gerekiyor.

İyi geceler arkadaşlar...

Edit; Koddaki ufak hataları düzelttim...

Link to comment
Share on other sites

msgbox(0,"deneme",_GoogleTranslate("Hello World!", "en","ja"))

Func _GoogleTranslate($sText, $sFrom = "en", $sTo = "ja")
	Local Const $FileName = "Translation.jsn"
	Local Const $Pattern = '"translatedText":"([^"]+)"'
	Local $GoogleURL = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=%s&langpair=%s%%7C%s"
	Local $File

	$GoogleURL = StringFormat($GoogleURL, $sText, $sFrom, $sTo)

	If Not InetGet($GoogleURL, $FileName, 1) Then Return SetError(1, 0, 0)

	$File = FileOpen($FileName, 4)
	FileGetSize($FileName)
	$Translation = FileRead($File, FileGetSize($FileName))
	FileClose($File)
	FileDelete($FileName)

	$Translation = BinaryToString($Translation, 4)

	If StringRegExp($Translation , $Pattern) Then
    	$Translation = StringRegExp($Translation , $Pattern, 1)
    	$Translation = $Translation[0]

    	Return $Translation
	EndIf
EndFunc

Link to comment
Share on other sites

@blackman12

Bazen kafa duruyor :) Ilk bakmamız gerek yeri unutuyoruz :)

Ama bu örnekte Azerice desteklenmiyor :(

;http://www.autoitscript.com/forum/index.php?showtopic=79606
_GoogleToMsgBox("Hello World", "en", "en")
_GoogleToMsgBox("Hello World", "en", "tr")
_GoogleToMsgBox("Hello World", "en", "az")
_GoogleToMsgBox("Hello World", "en", "ja")
_GoogleToMsgBox("Hello World", "en", "es")
_GoogleToMsgBox("Hello World", "en", "it")
_GoogleToMsgBox("Hello World", "en", "zh-cn")
_GoogleToMsgBox("Hello World", "en", "ar")
_GoogleToMsgBox("Hello World", "en", "bg")
_GoogleToMsgBox("Hello World", "en", "fr")
_GoogleToMsgBox("Hello World", "en", "de")
_GoogleToMsgBox(InputBox("You try it!", "Enter some text to translate to Russian", "In Soviet Russia, code document you!"), "en", "tr")

Func _GoogleToMsgBox($sText, $sFrom, $sTo)
	Msgbox(4096, "Google Translate [" & $sFrom & ":" & $sTo & "]", $sText & @TAB & @TAB & @TAB & @CRLF & @CRLF & _GoogleTranslate($sText, $sFrom, $sTo))
EndFunc

Func _GoogleTranslate($sText, $sFrom = "en", $sTo = "ja")
    Local Const $Pattern = '"translatedText":"([^"]+)"'
    Local $GoogleURL = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=%s&langpair=%s%%7C%s"

    $GoogleURL = StringFormat($GoogleURL, $sText, $sFrom, $sTo)
	$Translation = InetRead($GoogleURL, 1)
	If @error Then Return SetError(1, 0, 0)
    $Translation = BinaryToString($Translation, 4)

    If StringRegExp($Translation , $Pattern) Then
        $Translation = StringRegExp($Translation , $Pattern, 1)
        $Translation = $Translation[0]

        Return $Translation
    EndIf
EndFunc

@Aqil990

Senin için @blackman12 verdiği yukarıdaki örnek yeterli mi? Yoksa illa Azerice mi olsun diyorsun?

Link to comment
Share on other sites

tesekkurler blackman12 verdigini daha once gormusdum

benim istedigim kendim yapmak :D

yontemini nasil yaparim hangi kodlarla bir sunu anlatirsan sevinirim

ben sayfanin sourcesin yukledim

google javascriptden yararlaniyor form bulamadim

nasil olacak? :D

Link to comment
Share on other sites

fonksiyon googleın kendi özelliğinden yararlanmış.

"

Please register to see this content.
bu linkteki değişkenleri doldurunca translate yapılıyor.Daha sonra fonksiyonu yazan kişi bu değişkenleri string formatla belirlemiş.Belirledikten sonra istediği cevap olan değişkeni inetread ile okutmuş.Sonra stringe dönüştürmüş. Elde ettiği stringde

"translatedText"

içinde cevap gizliymiş ve burayı da strinregexp ile çözmüş. geriye kalan zaten translation.

Link to comment
Share on other sites

tamam KintaRo uzur dilerim, bundan sonra dikkat ederim, bu arada Azerice konusman harika :)

talha_252

Kardes inetgetle olmasada olar, simdi formun bildirib her hangi verini ceke bilmerizmi???

Yahşi cazibe dizisi sağolsun. Ordaki kadın çok güzel konuşuyor. Ondan öğrenmeye çalışıyorum. Çok güzel bir dil öztürkçe.

Link to comment
Share on other sites

Masaüstünü toplarken tekrar baktım. Aşağıdaki örnekte Azerice'de destekleniyor. Lakin unicode desteklenmiyor.

_GoogleToMsgBox("Hello world", "en", "en")
_GoogleToMsgBox("Hello world", "en", "tr")
_GoogleToMsgBox("Hello world", "en", "az")
_GoogleToMsgBox("Hello world", "en", "ch")
_GoogleToMsgBox("Hello world", "en", "ja")
_GoogleToMsgBox("Hello world", "en", "es")
_GoogleToMsgBox("Hello world", "en", "it")
_GoogleToMsgBox("Hello world", "en", "fr")
_GoogleToMsgBox("Hello world", "en", "de")

Func _GoogleToMsgBox($sText, $sFrom, $sTo)
	Msgbox(4096, "Google Translate [" & $sFrom & ":" & $sTo & "]", $sText & @TAB & @TAB & @TAB & @CRLF & @CRLF & _GoogleTranslate($sText, $sFrom, $sTo))
EndFunc

Func _GoogleTranslate($sText, $sFrom = "en", $sTo = "tr")
	$Translation = InetRead('http://translate.google.com/translate_a/t?client=t&text=' & $sText & '&hl=en&sl=' & $sFrom & '&tl=' & $sTo)
	If @error Then Return SetError(1, 0, 0)
	$Translation = StringRegExp(BinaryToString($Translation) , '"(?i)(.*?)"', 3)
	If @error Then  Return SetError(2, 0, 0)
	If StringStripWS($Translation[0],3) = "" Then Return $Translation[2]
	Return $Translation[0]
EndFunc

Link to comment
Share on other sites

  • 2 hafta sonra ...

Cok tesekkur ederim.

Kardesh peki sunu unicode yapa bilirmiyiz? autoitdle mumkunmu??

Aklima bir sey geldi simdi mesela ben inputa yazdiricam azeri sozleri

ю boyle simvollar olacak simdi biz inputa arama fonksiyonu koya bilmerizmi?

yani ю sunu bulan gibi ş sununla degissin???

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...