Are you looking for my non-technical blog?

This is now my technical-only blog, my non-technical blog is here.

07 January 2006

PyFusker

Python implementation of Fusker Introduction: Most probably you are redirected from Wikipedia to this page, so please if you have any comment on the code just leave it here so that I can improve it. Also if you can help me know why are people interested in the fusker technology that much, and what web sites do you usually fusker.
The Python Code
#!/usr/bin/python
""" PyFusker """
""" Author: Tarek Amr """
""" Version: 0.1 """
""" File: pyfusker.py """
""" Date: 07 January 2006 """
""" Replce [TAB] with \t """
class Fusker:
[TAB]def __init__(self, url):
[TAB][TAB]self.url = url
[TAB][TAB]self.urls = []
[TAB][TAB]self._generate()
[TAB]def _generate(self):
[TAB][TAB]comp = re.compile("\\[.+\\]")
[TAB][TAB]x = comp.findall(self.url)
[TAB][TAB]if not x:
[TAB][TAB][TAB]print "Url parsing error!"
[TAB][TAB][TAB]sys.exit()
[TAB][TAB]try:
[TAB][TAB][TAB]x[0] = x[0].strip("[")
[TAB][TAB][TAB]x[0] = x[0].strip("]")
[TAB][TAB][TAB]x1,x2 = x[0].split("-")
[TAB][TAB][TAB]x1 = string.atoi(x1)
[TAB][TAB][TAB]x2 = string.atoi(x2)
[TAB][TAB]except:
[TAB][TAB][TAB]print "Url parsing error!"
[TAB][TAB][TAB]sys.exit()
[TAB][TAB]if x1 > x2:
[TAB][TAB][TAB]print "Invalid range"
[TAB][TAB][TAB]sys.exit()
[TAB][TAB]temp_url = comp.split(url)
[TAB][TAB]i = x1
[TAB][TAB]while i < x2 :
[TAB][TAB][TAB]self.urls.append(string.join(temp_url,"%s" % i))
[TAB][TAB][TAB]i = i + 1
[TAB][TAB]return self.urls
[TAB]def list_urls(self):
[TAB][TAB]print self.urls
[TAB]def download_urls(self):
[TAB][TAB]for u in self.urls:
[TAB][TAB][TAB]try:
[TAB][TAB][TAB][TAB]print "Downloading ... ", u
[TAB][TAB][TAB][TAB]os.system("wget %s" % u)
[TAB][TAB][TAB]except:
[TAB][TAB][TAB][TAB]print "Wget Error!"
[TAB][TAB][TAB][TAB]continue
if __name__ == "__main__":
[TAB]try:
[TAB][TAB]url = sys.argv[1]
[TAB]except:
[TAB][TAB]print "Usage: python fusker.py http://www.website.com/img[01-06].jpg"
[TAB][TAB]sys.exit()
[TAB]f = Fusker(url)
[TAB]f.download_urls()
Tags: , ,