erguntunc Posted December 6, 2013 Share Posted December 6, 2013 (edited) karaladım birşeyler ama olmadı url varsa input içine yazsın istiyorum #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form = GUICreate("Adres kontrol", 429, 216) $siteurl = GUICtrlCreateInput("", 120, 72, 169, 21) $Label2 = GUICtrlCreateLabel("Örnek:http://tnctr.com", 120, 40, 167, 20) $varmiyokmu = GUICtrlCreateButton("varmı yokmu", 108, 160, 195, 33) $Input1 = GUICtrlCreateInput("", 64, 110, 337, 21) $Label3 = GUICtrlCreateLabel("Adres", 16, 112, 31, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $varmiyokmu $HTTP.Open("GET", $siteurl) $var = $siteurl if $var = $siteurl Then GUICtrlSetData($Input1, GUICtrlRead($siteurl) & "/egitim") Else GUICtrlSetData($Input1, GUICtrlRead($siteurl) & "Böyle bir url yok") Endif EndSwitch WEnd Edited December 6, 2013 by erguntunc Quote Link to comment Share on other sites More sharing options...
MostWanted Posted December 6, 2013 Share Posted December 6, 2013 (edited) $HTTP.Open("GET", $siteurl)gibi kullanımı neye göre yaptın açıkçası anlayamadım?Yapmak istediğin şeyi de açıkçası anlayamadım.Eğer girilen şey url değil mi diye anlamak istiyorsan şöyle bi kalıp kullanabilirsin.$a = StringRegExp($sURL, "(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?")eğer url ise 1 döner değilse 0. Edited December 6, 2013 by MostWanted Quote Link to comment Share on other sites More sharing options...
erguntunc Posted December 7, 2013 Author Share Posted December 7, 2013 Hayır hocam öyle demek istemedim $siteurl input'a girilen urlnin /egitim uzantısı varmı yokmu onu kontrol etmek istiyorum mesela kullanıcı $siteurl inputuna http://tnctr.com girdi diyelim /forum/97-autoit/ uzantısı varmı sitede yokmu onu kontrol etmek istiyorum varsa Input1 içine http://tnctr.com/forum/97-autoit/ yazsın yoksa Böyle bir url yok yazsın böyle demek istemiştim. Quote Link to comment Share on other sites More sharing options...
MostWanted Posted December 7, 2013 Share Posted December 7, 2013 (edited) #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form = GUICreate("Adres kontrol", 429, 216) $siteurl = GUICtrlCreateInput("", 120, 72, 169, 21) $Label2 = GUICtrlCreateLabel("Örnek:http://tnctr.com", 120, 40, 167, 20) $varmiyokmu = GUICtrlCreateButton("varmı yokmu", 108, 160, 195, 33) $Input1 = GUICtrlCreateInput("", 64, 110, 337, 21) $Label3 = GUICtrlCreateLabel("Adres", 16, 112, 31, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $varmiyokmu $sURL = GUICtrlRead($siteurl) $linkontrol = StringRegExp($sURL, "(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?") if $linkontrol then $isExist = HttpGet($sURL, "/eğitim") ;eğitimden başka bişi aramak istiyorsan burayı değiştir if $isExist Then GUICtrlSetData($Input1, GUICtrlRead($siteurl) & "/egitim") Else GUICtrlSetData($Input1, "Böyle bir url yok") Endif Else MsgBox(0, "Hata", "Girdiğiniz url geçerli değil!") EndIf EndSwitch WEnd Func HttpGet($sURL, $sPath = "") Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") if StringLeft($sPath, 1) <> "/" then $sPath = "/" & $sPath $oHTTP.Open("GET", $sURL & $sPath , False) If (@error) Then Return SetError(1, 0, 0) $oHTTP.Send() If (@error) Then Return SetError(2, 0, 0) If ($oHTTP.Status = 200) Then Return True Return False EndFuncKod gayet güzel çalışıyor fakat şöyle bi açığı var şimdiden görebiliyorum.Diyelim ki server çöktü veya herhangi bi nedenden dolayı o sayfaya ulaşılamazsa da bu kod "böyle bi link yok" diye dönecek.Bunu ; If ($oHTTP.Status = 200) Then Return Truesatırını If ($oHTTP.Status <> 404) Then Return Trueyaparak çözebilirsin.Ancak bu sefer de diyelim ki sayfa yok ama server da problem varsa kod o sayfa var diye dönecektir.Neyse çok önemli bir şey olmadığını varsayarak o durumları yoksaydım.Kısaca bağlantı da veya server da sorun yoksa bu kod çalışır :) . (Bu arada bu çocuk beni azarladı sonra gitti http get kullandı demeyesin diye not düşeyim, objeyi olutşturmadan önce http kullanmışsın ve copy paste yaptığın çok belli oluyordu çünkü en az bi kere çalıştırsan compile bile olmadığını görecektin.) Edited December 7, 2013 by MostWanted Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.