-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLevel 6.py
More file actions
36 lines (28 loc) · 777 Bytes
/
Level 6.py
File metadata and controls
36 lines (28 loc) · 777 Bytes
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
from urllib.request import urlopen
import re
import zipfile
html = urlopen("http://www.pythonchallenge.com/pc/def/channel.html").read()
print(html)
# Replace with zip
# Replace html with zip
'''
prev = "90052"
for i in range(911):
filename = "channel/"+prev+".txt"
file = open(filename,'r')
ss = file.read()
print(ss)
prev = re.findall(r'[0-9]{1,}',ss)[0]
print(prev)
'''
# Getting both the numbers and comments
f = zipfile.ZipFile("channel.zip")
prev = "90052"
comments = []
for i in range(908):
ss = f.read(prev + ".txt").decode("utf-8")
comments += [f.getinfo(prev + ".txt").comment.decode("utf-8")]
print(ss)
prev = re.findall(r'[0-9]{1,}', ss)[0]
print(prev)
print("".join(comments))