美文网首页
The Python Challenge(8)

The Python Challenge(8)

作者: 发条蛙 | 来源:发表于2017-10-20 18:10 被阅读0次

问题链接

问题链接如下:

http://www.pythonchallenge.com/pc/def/oxygen.html

答案链接

答案链接如下:

http://www.pythonchallenge.com/pc/def/integrity.html

解题思路

页面和源码中无任何提示,但图片中有一条很明显的灰度线,考虑到灰度图取值范围为[0, 255],不妨将其转为ASCII码查看,则有如下代码:

from urllib import request
from PIL import Image

url = 'http://www.pythonchallenge.com/pc/def/oxygen.png'
response = request.urlopen(url)
oxygen = Image.open(response)
oW, oH = oxygen.size
h = oH // 2
msg = ''
# 这里的7来源于:不设置该数字时,输出结果可以看到明显的重复7次。
for w in range(0, oW, 7):
    pixel = oxygen.getpixel((w, h))
    msg  += chr(pixel[0])

print(msg)

输出信息为:

smart guy, you made it. the next level is [105, 110, 116, 101, 103, 114, 105, 116, 121]pe_

将中括号内的数字再次转换为ASCII,则有如下代码:

from urllib import request
from PIL import Image

url = 'http://www.pythonchallenge.com/pc/def/oxygen.png'
response = request.urlopen(url)
oxygen = Image.open(response)
oW, oH = oxygen.size
h = oH // 2
msg = ''
for w in range(0, oW, 7):
    pixel = oxygen.getpixel((w, h))
    msg  += chr(pixel[0])

# print(msg)

s = msg.index('[')
e = msg.index(']')
code = msg[s+1:e].split(',')
for c in code:
    print(chr(int(c)), end='')

print('')

最终输出结果:

integrity

替换原始URL中的对应位置可以得到最终URL为:http://www.pythonchallenge.com/pc/def/integrity.html

相关文章

  • Python挑战:00~03关

    Python Challenge Python Challenge 00 网址: http://www.pytho...

  • The Python Challenge(8)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 页面和源码中无任何提示,但图片中有一条很明显的灰度线...

  • Python Challenge[8]

    [Level 8] Title: working hard? Where is the missing link?...

  • Python挑战:04-05关

    Python Challenge Python Challenge 04 现在,我们来挑战第四关,从第三关的结果,...

  • [Python Challenge通关]第8关 working

    Where is the missing link? 挑战地址,点我 分析 点击蜜蜂,提示需要输入用户名和密码: ...

  • python马丁Challenge8.Finding parti

    Finding particular sequences of prime numbersInsert your ...

  • The Python Challenge(5)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 根据页面源码提示: 再点击页面图片显示: 可知是需要...

  • The Python Challenge(9)

    问题链接 问题链接如下: 答案链接 答案链接如下: 登陆用户名密码为huge和file。 解题思路 阅读源码有如下...

  • The Python Challenge(2)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 将页面给定的字符串根据给定规则进行替换即可,规则如下...

  • The Python Challenge(3)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 根据页面提示: 阅读源码,有如下内容: 编写代码从中...

网友评论

      本文标题:The Python Challenge(8)

      本文链接:https://www.haomeiwen.com/subject/sfvvuxtx.html