Python Crawler
Posted on April 16, 2006
(Last modified on June 25, 2011)
|
|
0 comment
This IMO is one of the dirtiest way for me up till now to accomplish a
requirement. But it does the job I want. :D
_ DISCLAIMER: I’m a learner. There must be better, smarter and easier way to
accomplish the same task._
rrs@learner:~/My_Documents/My Books $ cat
/home/rrs/devel/eclipse/PythonFun/web_pattern_fetcher.py
#!/usr/bin/env python
"""
This tiny little script does the job of crawling into Apache generated
directory listings
and download scanning a specific pattern.
I'm using it to download anything that apache shows as TXT or IMG.
I'm sure others will be able to extend it more.
"""
import urllib, urllib2, string
url = "http://www.wuppy.net.ru/Fun/"
req = urllib2.Request(url)
handle = urllib2.urlopen(req)
x = 1
data = ''
while x:
data = ''
line = handle.readline()
if "[TXT]" in line or "[IMG]" in line:
word_list = line.split(' ')
word = word_list[4:5]
req_word = str(word)
# Break and take out the relevant data uri
begin_num = req_word.find(">")
end_num = req_word.find("</A" )
req_word = list(req_word)
while begin_num < end_num - 1:
final_word = string.lstrip( string.rstrip(str(req_word[begin_num+1:begin_num+2]), "']"), "['")
data += final_word
begin_num += 1
#data.append(req_word[begin_num+1:begin_num+2])
real_url = url + data
urllib.urlretrieve(real_url, data)
if line == '':
x = 0
Pythonic Addiction
Posted on April 15, 2006
(Last modified on January 22, 2011)
|
|
0 comment
#!/usr/bin/env python
def files(root):
for path, folders, files in os.walk(root):
for file in files:
yield path, file
def find_match(repository): # aka walk_tree_copy()
for path, file in files(repository):
if file.endswith ('html') or file.endswith ('htm') or file.endswith ('HTML') or file.endswith ('HTM'):
#if file.endswith ('html.gz') or file.endswith ('htm.gz') or file.endswith ('HTML.gz') or file.endswith ('HTM.gz'):
try:
os.environ['__TEMP__VAL'] = file
os.chdir(path) # We need to chdir so that gzip can see the file in the cwd
os.system('gzip $__TEMP__VAL')
sys.stdout.write("%s/%s has been gzipped\n" % (path, file))
except IOError:
sys.stdout.write("Aieeeee.... I got some error with %s!\n\n" % (file))
continue
#return True
return False
def main():
REPOSITORY = raw_input("Please enter a path to look for the files to zip.\nHit Return Key if you want the default path i.e. \"/home/rrs/My_Documents/My Books\"")
if REPOSITORY == '':
REPOSITORY = "/home/rrs/My_Documents/My Books/"
find_match(REPOSITORY)
if __name__ == '__main__':
import os, sys, shutil
main()
Ritesh Sarraf Ticketed Again
Posted on April 12, 2006
(Last modified on January 22, 2011)
|
|
0 comment
Secure P2P Sharing
Posted on March 30, 2006
(Last modified on January 31, 2013)
|
|
0 comment
First,
DISCLAIMER: I ’m not a guru, I’m just a learner. So there might be a chance
that the whole article might be fundamentally wrong.
I thought of this because I use P2P network a lot.
On my laptop, which is the repository of everything I have, it is necessary
for me to make sure that it is secure enough.
To firewall it I use the single rule from iptables:
[Read More]Back In Business
Posted on March 30, 2006
(Last modified on January 22, 2011)
|
|
0 comment
Wow!
Overall it has been a complete rediscovered experience switching from own
webservers to a web-hosting service provider’s servers.
It took me almost a full week to get back pivot working on the foreign host. I
really miss my servers. Cam, if you can listen that, “You made me have a week
of tiring
time”.
iprint - Andrew "Tridge" Tridgell's iprint in Python
Posted on February 5, 2006
(Last modified on January 22, 2011)
|
|
0 comment
Following code does the same thing that Tridge’s iprint.c does.
#!/usr/bin/env python
import sys
"iprint - Andrew \"Tridge\" Tridgell's iprint in Python"
def toBinary(dec):
"""
This function does the coversion from integer to binary
"""
bin = ''
while dec:
bin = (dec % 2 and '1' or '0') + bin
dec = long(dec/2)
return bin or '0'
x = 1
text = ''
while len(sys.argv) > 1 and x < len(sys.argv):
text += sys.argv[x]
x += 1
for x in text:
print ord(x), "\t", hex(ord(x)), "\t", oct(ord(x)), "\t", toBinary(ord(x)), "\t", x
print "\n"
Ravi's MotoRazor V3
Posted on January 18, 2006
(Last modified on June 15, 2011)
|
|
0 comment
This is a picture from Ravi’s recently purchased
MotoRazor V3
Dhuen mein hai baadal, baadal mein hai khoobsurati;
khoobsurati mein basti hai zindagi;
Aye zindagi kyon hai yeh dhuan ???
Lonely Nights
Posted on December 21, 2005
(Last modified on January 22, 2011)
|
|
0 comment
Recently after my vacation to home I regained my usual life, The Lonely
Nights

Almost every night morning while I try to sleep I get weird feelings.
Feelings like there’s a snake crawling on my legs over the quilt. The feeling
like it’s moving towards me and will bite me right at my neck so that I have
no possibilities of fighting back to death. Also the scorpion that’s stuck
under my pillow, comes out in anguish and hits me at the neck.
[Read More]Customizing Gallery ver 1
Posted on December 4, 2005
(Last modified on January 22, 2011)
|
|
0 comment
Customizing Gallery ver 1 is as simple as adding your HTML code into
respective wrapper.header.html and wrapper.footer.html files at the
end, after all the PHP code, in the html_wrap directory.
Simple, Isn’t it!
What a lovely OS
Posted on October 23, 2005
(Last modified on January 22, 2011)
|
|
0 comment
Really, What a lovely OS is Debian.
I must admire its technical design. Recently I had to wipe out my hard drive
for some reasons. I had put a lot of effort into selection of packages and
configuration as per my taste.
And guess what, re-installation is a cool breeze in Debian. Every setting
and every package (from multiple sources) were back. I use a mixture of
Testing + Unstable + Experimental + (Some other apt sources) on my laptop.
[Read More]