pythonchallenge_level9

简介: pythonchallenge各关解题

level9

地址:http://www.pythonchallenge.com/pc/return/good.html
源码:git@code.aliyun.com:qianlizhixing12/PythonChallenge.git。
问题:使用PIL.Image对象show连接源码中first,second点。

#!/usr/bin/env python3
# -*- coding:UTF-8 -*-

# Level 9

import os
import urllib.request

url = "http://www.pythonchallenge.com/pc/return/good.html"
userinfo = {"realm":"inflate", "uri":url, "user":"huge", "passwd":"file"}
# create a password manager
password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
# Add the username and password
password_mgr.add_password(**userinfo)
# create "opener" (OpenerDirector instance)
handler = urllib.request.HTTPBasicAuthHandler(password_mgr)
# create "opener" (OpenerDirector instance)
opener = urllib.request.build_opener(handler)
'''
方式一
# use the opener to fetch a URL
x = opener.open(url)
print(x.read())
'''
# 方式二Install the opener.all calls to urllib.request.urlopen use our opener.
urllib.request.install_opener(opener)

response = urllib.request.urlopen(url)
body = response.read().decode("utf8")
response.close
    
import re

stmp = re.findall("first:\n((?:.|\n)*)\n\nsecond:((?:.|\n)*)\n\n-->", body)
first, second = stmp[0][0].replace("\n", "").split(","), stmp[0][1].replace("\n", "").split(",")
first, second = list(map(int, first)), list(map(int, second))

import PIL.Image
import PIL.ImageDraw

img = PIL.Image.new("RGB", (640, 480))
draw = PIL.ImageDraw.Draw(img)
draw.line(first)
draw.line(second)
img.show()
相关文章
|
5月前
[WUSTCTF 2020]level3
[WUSTCTF 2020]level3
36 0
|
开发框架 Java API
J2EE Specification Level
J2EE Specification Level
118 0
0227show all segment level statistics
[20180227]show all segment level statistics.txt https://orainternals.wordpress.com/2013/06/12/dude-where-is-my-redo/ REM Author : Ri...
1020 1
|
关系型数据库 测试技术 Oracle
[20180102]statistics_level=BASIC.txt
[20180102]statistics_level=BASIC.txt --//一个测试环境不知道谁设置statistics_level=BASIC,导致重启出现错误,自己在测试环境模拟看看: SYS@book> create pfile='/tmp/@.
1259 0
|
Python
pythonchallenge_level2
pythonchallenge各关解题
1131 0
|
Python
pythonchallenge_level6
pythonchallenge各关解题
1139 0
|
Python
pythonchallenge_level0
pythonchallenge各关解题
1160 0