# coding=UTF-8
"""
download the directory
13/09/04 kingson
* add this changelog
Notes:
1. make sure the path is empty, otherwise mkdir complain and stoped
2. the time for sleep() varies dependent on sites
3. tested for FireBird BBS only
Bugs:
1.
TODO:
1. add some GUI for control, e.g. stop, pause, resume, inside script
2. make it robust
"""
import fqterm
import sys,os,string,time,re
# the pointer to fqtermWindow object
lp=long(sys.argv[0])
wait_time = 2.0
def txt2html(txt):
txt=string.replace(txt,"\n","\n
")
return string.replace(txt," "," ")
def upper_dir(path):
if(sys.platform=="win32"): # '\' for win32
i=path.rfind("\\",0,-1)
else:
i=path.rfind("/",0,-1) # '/' for *nix
return path[:i+1]
def lower_dir(path, subdir):
if(sys.platform=="win32"): # '\' for win32
return path+subdir+"\\"
else:
return path+subdir+"/" # '/' for *nix
def write_html_header(hfile, num):
hfile.write("""
FQTerm Article Downloader
FQTerm --- BBS client based on Qt library
") hfile.write("""
http://code.google.com/p/fqterm
""") hfile.write("") hfile.write("") def write_index_header(hfile): hfile.write("""
FQTerm Article Downloader
FQTerm --- BBS client based on Qt library
") hfile.write("""
http://code.google.com/p/fqterm
""") hfile.write("") hfile.write("