def do_compute(self): # step 1. Get hint from page source hint = TextHelper.find_text_between_tag(self.web_source, "<html> <!-- <-- ", " -->\n<head>") zip_url = WebHelper.change_suffix_url(self.url, hint) # step 2. Download zip to local and extract tmp_zip = zip_url[zip_url.rindex("/") + 1:] tmp_folder = tmp_zip[:tmp_zip.index(".")] WebHelper.download(zip_url, tmp_zip) zip_ref = zipfile.ZipFile(tmp_zip, 'r') zip_ref.extractall(tmp_folder) zip_ref.close() # step 3. Get next hint readme_txt = open(tmp_folder + "/readme.txt", 'r').read() start_txt = TextHelper.find_text_between_tag(readme_txt, "hint1: start from ", "\n") next_hint = T6.read_traverse(start_txt) print next_hint # Hint: Collect the comments. # step 4. Get comments print T6.collect_comments( tmp_zip, start_txt) # Comments: HOCKEY (Small letter oxygen) # step 5. Wrong way wrong_url = WebHelper.join_url(self.url, "hockey") print WebHelper.get_web_source( wrong_url) # it's in the air. look at the letters. # step 6. Get next url hint self.set_prompt(WebHelper.join_url(self.url, "oxygen")) # step 7. Clean folder FileHelper.remove_folder(tmp_folder) FileHelper.remove_file(tmp_zip)
def do_compute(self): # step 1. Get banner dump data banner_prompt = TextHelper.find_text_between_tag( self.web_source, "peakhell src=\"", "\"/>") banner_url = WebHelper.join_url(self.url, banner_prompt) banner_data = WebHelper.get_web_source(banner_url) # step 2. show the banner banner = '' for line in pickle.loads(banner_data): for char, count in line: banner += char * count banner += '\n' print banner # Get word channel # step 3. Set prompt self.set_prompt("channel")