Ömer Ücel

October 11, 2007

Python Bağlantı Bulucu

Filed under: Genel — Tags: — Ömer Ücel @ 6:34 pm

Verilen adresteki bağlantıların listesini almaya yarayan bir python betiği.

  1. # -*- coding:cp1254 -*-

  2. #!/usr/bin/python

  3.  

  4. import re

  5. import urllib2

  6. import threading

  7.  

  8. class Bul(threading.Thread):

  9. def __init__(self,URL,ayrac1,ayrac2):

  10. self.URL=URL

  11. self.ayrac1=ayrac1

  12. self.ayrac2=ayrac2

  13. threading.Thread.__init__(self)

  14.  

  15. def run(self):

  16. try:

  17. if self.URL[len(self.URL)-1:len(self.URL)]=="/":

  18. self.URL=self.URL[0:len(self.URL)-1]

  19. dosya=urllib2.urlopen(self.URL).read()

  20. dosya=dosya.upper()

  21. dosya=re.split(self.ayrac1,dosya)

  22. for a in range(len(dosya)):

  23. durum = re.search(self.ayrac2,dosya[a])

  24. if durum:

  25. if str(durum.expand(r"\1"))[0:7]=="HTTP://":

  26. Link=str(durum.expand(r"\1"))

  27. else:

  28. if str(durum.expand(r"\1"))[0:1]=="/":

  29. Link=str(self.URL) + str(durum.expand(r"\1"))

  30. else:

  31. Link=str(self.URL) + "/" + str(durum.expand(r"\1"))

  32. print Link.lower()

  33. print "İşlem bitti"

  34. except Exception,hata:

  35. print hata

  36. Bul("http://www.omerucel.com","<.?A",'href="([^"]*)"').start()

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress