import sys import os from pycaptcha import download, image, captcha def test(url, di_name): if not os.path.exists(di_name): os.mkdir(di_name) os.chdir(di_name) html = open('result.html', 'w') html.write('') html.flush() html.close() def parse_captcha(url, filename): data = download.url_to_image_data(url) img_file = open(filename, 'w') img_file.write(data) img = image.image_data_to_tiff(data) text = captcha.image_to_text(img) return text if __name__ == '__main__': url = sys.argv[1] di_name = sys.argv[2] test(url, di_name)