-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path29.py
36 lines (28 loc) · 814 Bytes
/
29.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import download_file
import bz2
def main():
url = "http://www.pythonchallenge.com/pc/ring/guido.html"
file_path = "silent/guido.html"
user = "repeat"
password = "switch"
# first_step(url, file_path, user, password)
second_step(file_path)
def first_step(url, file_path, user, password):
download_file.download_with_auth(url, file_path, user, password)
def second_step(file_path):
file = open(file_path, "r")
count = 0
result = ""
while True:
count += 1
line = file.readline()
if line:
if count >= 13:
result += chr(len(line) - 1)
else:
break
print("result = " + result)
dec_result = bz2.decompress(result.encode("latin1"))
print(dec_result)
if __name__ == "__main__":
main()