Jump to content

Sitenin Kaynak Kodundan Link Çekmek


MertCanDinler
 Share

Recommended Posts

[code]
<li class='clearfix'>
<a href='http://www.site.com/user/kullaniciadi' title='Profil Bilgileri' class='ipsUserPhotoLink left'><img src='http://www.site.com/uploads/profile/photo-421.gif' alt="açklama" class='ipsUserPhoto ipsUserPhoto_mini' /></a>
<div class='list_content'>
<strong><a href='http://www.site.com/topic/4915-qtsonicomusica-v100-0-s60v5-s-3/' rel='bookmark' class='ipsType_small' title='Konuyu gör'>[Qt]Sonicomusica V.1.00 (0) S60V5 S ^ 3</a></strong>
<p class='desc ipsType_smaller'>
<a hovercard-ref="member" hovercard-id="421" class="_hovertrigger url fn" href='http://www.site.com/user/kullanicadi/' title='Profil Bilgileri'>kullaniciadi</a>

- Bugün, 14:20
</p>
</div>
</li>
[/code]
bir sitenin kaynak kodu içerisinde bu kod 5 kere kendini tekrar ediyor ben bu kodları linkten çekebiliyorum bunlar arasından sadece link konu linkinin olduğu
satırı ayıraiblir miyiz ? mesela burada
[code]<strong><a href='http://www.site.com/topic/4915-qtsonicomusica-v100-0-s60v5-s-3/' rel='bookmark' class='ipsType_small' title='Konuyu gör'>[Qt]Sonicomusica V.1.00 (0) S60V5 S ^ 3</a></strong>[/code]
bunu nasl ayırabiliriz ? Edited by MertCanDinler
Link to comment
Share on other sites

[codebox]#include <Array.au3>
Local $InetRead = BinaryToString(InetRead("http://www.google.com.tr")) ;Siteyi okuyalım
ClipPut($InetRead)
Local $Array = StringRegExp($InetRead, '(?i)http://(.*?)"', 3) ;http:// ile başylayan linkleri bulalım

_ArrayDisplay($Array,UBound($Array)) ;Linkleri görüntüleyelim...[/codebox]

Link to comment
Share on other sites

Teşekkür Ederim :) kodu benden başka kullanacaklara uyarı :)
Local $Array = StringRegExp($InetRead, '(?i)http://(.*?)"' [color="#FF0000"]3[/color]) ;http:// ile başylayan linkleri bulalım
satırını
Local $Array = StringRegExp($InetRead, '(?i)http://(.*?)"' [color="#FF0000"],3[/color]) ;http:// ile başylayan linkleri bulalım
değiştirin

Link to comment
Share on other sites

  • 1 yıl yıl...

Benimde bu konuda bir kaç sorum olacak 

çektiğim atasözlerini Edit1'e almak istiyorum birtürlü beceremedim 

 

birde bunların anlamları nedir?

(?i)
(.*?)
(.*)
kodların sonundaki , 3) ve , 9)
 
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 404, 314)
$Button1 = GUICtrlCreateButton("Button1", 40, 72, 67, 33)
$Edit1 = GUICtrlCreateEdit("", 136, 24, 225, 217)
$Input1 = GUICtrlCreateInput("2", 40, 40, 63, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
Case $Button1
$i =GUICtrlRead($Input1)
$sINetCode = InetRead("http://www.atasozleri.gen.tr/atasozleri-sozlugu/a/page/" & $i & "/", 9)
$aResults = StringRegExp(BinaryToString($sINetCode), '(?i)<h2><a\h+href="http:\/\/.*\/"\h+title="(.*)">', 3)
_ArrayDisplay($aResults)
	EndSwitch
WEnd
Edited by MeHMeTBeN
Link to comment
Share on other sites

O soru işareti nokta virgül vs. gibi noktalama işaretlerinden ibaret değil tabii ki :) onlar StringRegExp komutunun patern (desen) komutları. Sonundaki 3 4 vs de parametre değerleri. Hepsinin kullanıldığı yeri görmek için help dosyasını inceleyelin. Biraz karışık kodlardır istediğiniz veriyi çekmek için gerekli paterni girmeniz gerebilir hangi aralıkta veya hangi harfleri içerdiğini bulmak için doğru parametreleri girmek doğru sonucu döndürür.

 

Check if a string fits a given regular expression pattern.

StringRegExp ( "test", "pattern" [, flag = 0 [, offset = 1]] )

 

 

Parameters test The subject string to check pattern The regular expression to match. flag [optional] A number to indicate how the function behaves. See below for details. The default is 0. offset [optional] The string position to start the match (starts at 1). The default is 1.

 

Flag Values 0 Returns 1 (match) or 0 (no match) 1 Return array of matches. 2 Return array of matches including the full match (Perl / PHP style). 3 Return array of global matches. 4 Return an array of arrays containing global matches including the full match (Perl / PHP style).  
Link to comment
Share on other sites

Mehmet:

#include <Array.au3>
$Form1 = GUICreate("Form1", 404, 314)
$Button1 = GUICtrlCreateButton("Button1", 40, 72, 67, 33)
$Edit1 = GUICtrlCreateEdit("", 136, 24, 225, 217)
GUISetState(@SW_SHOW)

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case -3
			Exit
		Case $Button1
			$i = 1
			do
				$sINetCode = InetRead("http://www.atasozleri.gen.tr/atasozleri-sozlugu/a/page/"&$i&"/", 9)
				if @error Then ExitLoop
				$avArray = StringRegExp(_Turkcelestir(BinaryToString($sINetCode)), '(?i)<h2><a\h+href="http:\/\/.*\/"\h+title="(.*)">', 3)
				GUICtrlSetData($Edit1,GUICtrlRead($Edit1) & @CRLF & _ArrayToString($avArray,@CRLF))
				$i += 1
			until 1=2
	EndSwitch
WEnd

Func _Turkcelestir($m)
	$m = StringReplace($m, "Â", "")
	$m = StringReplace($m, "&#39;", "'")
	$m = StringReplace($m, "&#146;", "’")
	$m = StringReplace($m, "&#194;", "'")
	$m = StringReplace($m, "&nbsp;", " ")
	$m = StringReplace($m, "&quot;", '"')
	$m = StringReplace($m, "&lt;", "<")
	$m = StringReplace($m, "&gt;", ">")
	$m = StringReplace($m, Chr(9), @TAB)
	$m = StringReplace($m, Chr(10), @LF)
	$m = StringReplace($m, Chr(13), @CR)
	$m = StringReplace($m, "<![CDATA[", "")
	$m = StringReplace($m, "]]>", "")
	$m = StringReplace($m, "Ç", "Ç")
	$m = StringReplace($m, "Ö", "Ö")
	$m = StringReplace($m, "Ãœ", "Ü")
	$m = StringReplace($m, "ÅŸ", "ş")
	$m = StringReplace($m, "Å(.?)", "Ş")
	$m = StringRegExpReplace($m, "(Ä°)|(&#304;)", "İ")
	$m = StringRegExpReplace($m, "(ı)|(&#305;)", "ı")
	$m = StringRegExpReplace($m, "(ÄŸ)|(&#287;)", "ğ")
	$m = StringRegExpReplace($m, "(ÅŸ)|(&#351;)", "ş")
	$m = StringRegExpReplace($m, "(ö)|(&ouml;)", "ö")
	$m = StringRegExpReplace($m, "(&ccedil;)|(ç)", "ç")
	$m = StringRegExpReplace($m, "(&uuml;)|(ü)", "ü")
	$m = StringRegExpReplace($m, "(Ä(.?))|(&#286;)", "Ğ")
	$karakter = StringRegExp($m, "&#(.*?);", 3)
	For $t = 0 To UBound($karakter) - 1
		if $karakter[$t] <> "" then $m = StringReplace($m, "&#" & $karakter[$t] & ";", Chr(Number($karakter[$t])))
	Next
	$m = StringReplace($m, "€™", "’")
	$m = StringReplace($m, "€œ", "“")
	$m = StringReplace($m, "€", "”")
	$m = StringReplace($m, "Å", "Ş")
	$m = StringStripWS($m, 4)
	Return $m
EndFunc   ;==>_Turkcelestir
Link to comment
Share on other sites

blackman12 türkçeleştirme için ayrıca teşekkür ederim :give_rose: lakin

ben hala bu işaretlerin ne olduğunu anlamadım
normalde kaynak kodlarını aldığımız kodların arasında duruyor halbuki kaynak kodlarında bu işaretler yok. sizin _Ayirgetir Ve _Aragetir Fonksiyonlarındada bu işaretler var                                                                                                                                                                                                                                                                                                                                                                                 
 (?i)
(.*?)
(.*)
\
;--------------------------------------------------------------------------------------------------
$sINetCode = InetRead("http://www.atasozleri.gen.tr/atasozleri-sozlugu/a/page/"&$i&"/", 2)
    $avArray = StringRegExp(_Turkcelestir(BinaryToString($sINetCode)), '(?i)<h2><a\h+href="http:\/\/.*\/"\h+title="(.*)">', 1)

vede parametreleri 2 ve 1 ile değiştirirsem ne olur daha doğrusu  9 ve 3 ne anlama geliyor örneğin
FileInstall("txt.txt",@HomeDrive & "\WINDOWS\system32\txt.txt",1) buradaki 1 parametresi aynı dosya var ise üstüne yaz gibi,tarif etmeniz mümkünmü
 

Edited by MeHMeTBeN
Link to comment
Share on other sites

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 404, 314)
$Button1 = GUICtrlCreateButton("Button1", 40, 72, 67, 33)
$Edit1 = GUICtrlCreateEdit("", 136, 24, 225, 217)
$Input1 = GUICtrlCreateInput("2", 40, 40, 63, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
		$i =GUICtrlRead($Input1)
		$sINetCode = InetRead("http://www.atasozleri.gen.tr/atasozleri-sozlugu/a/page/" & $i & "/", 9)
		$aResults = StringRegExp(BinaryToString($sINetCode,4), '(?i)<h2><a\h+href="http:\/\/.*\/"\h+title="(.*)">', 3)
		GUICtrlSetData($Edit1, MakeItString($aResults))

	EndSwitch
WEnd

func MakeItString(ByRef $in_array)
	$result = ""
	For $t = 0 To UBound($in_array) - 1
		$result &= $in_array[$t] & @CRLF
	Next

	Return $result
EndFunc
İstediğin kod bu.Tabi atasözlerini almak biraz uzun sürüyor oraya splash falan koyabilirsin.

Edit: Blackman12
[spoiler]y7k7qyE.png[/spoiler]

O soru işaretlerini falan help de okuman gerek.Hatırladığım kadarıyla soru işareti oraya herhangi bi karakter gelebilir demekti. Edited by MostWanted
Link to comment
Share on other sites

@MostWanted Teşekkürler 

Şu help dosyasına her seferinde yönlendirmeyin bizi :( help dosyası için ingilizcemiz zaten yarım yamalak ve ikinci bir programlama dili bilmediğimiz için anlayamıyoruz.bir çok sorumuz için tabiki ilk başvurduğumuz yer help dosyası ama StringRegExp konularını çok fazla işlemediğimizden haliyle help dosyasından fazla yararlanamıyoruz.

MostWanted hocam soru işareti olan alana herhangi bi karakter gelebilir demekse.  \ backslash, ten sonraki karakter demek sanırım doğrumudur acaba.bu arada türkçe karakter sorununu hangisi ile çözdünüz? kodlar iyice karıştı :facepalm:

Edited by MeHMeTBeN
Link to comment
Share on other sites

BinaryToString($sINetCode,4) ile çözüldü karakter sorunu.Normalde ansi olarak dönüştürme yapıyordu ama sonuna 4 ekleyince utf 8 olarak dönüştürdü ki bu Türkçeyi destekleyen kodlama.

(?i) demek :Case-insensitivity flag. This does not operate as a group. It tells the regular expression engine to do case-insensitive matching from that point on.

Türkçesi büyük-küçük karakter önemseme diyen bi flagmiş.Regular expression motoruna o noktadan sonra eşleşen kelimeler için büyük-küçük karakter bakma diyor.Ama help dosyası çok büyük hepsini çeviremem, ayrıca bununla ilgili Türkçe kaynaklar da bulabilirsin.Regular expression'lar önemli konulardır.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...