-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlevel_09.py
44 lines (31 loc) · 983 Bytes
/
level_09.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
37
38
39
40
41
42
43
44
#!/bin/env python
# coding=utf-8
# http://huge:[email protected]/pc/return/good.html
# Connect the dots.
import re
import requests
from PIL import Image
from PIL import ImageDraw
PREFIX = "http://huge:[email protected]/pc/return/"
url = PREFIX + 'good.html'
def catch(text, pattern=r'<!--(.*?)-->', cnt=0):
return re.findall(pattern, text, re.DOTALL)[cnt]
def solve(something):
first, second = re.findall(
r'first:(.*?)second:(.*)', something.replace('\n', ''))[0]
l1 = list(map(int, first.split(',')))
l2 = list(map(int, second.split(',')))
return l1, l2
def plot(l1, l2):
im = Image.new("RGB", (640, 480))
draw = ImageDraw.Draw(im)
draw.polygon(l1)
draw.polygon(l2)
im.show()
if __name__ == "__main__":
r = requests.get(url)
something = catch(r.text, cnt=1)
answer = solve(something)
plot(*answer)
# bull graph
# http://huge:[email protected]/pc/return/bull.html