美文网首页
The Python Challenge(3)

The Python Challenge(3)

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

问题链接

问题链接如下:

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

答案链接

答案链接如下:

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

解题思路

根据页面提示:

recognize the characters. maybe they are in the book, 
but MAYBE they are in the page source.

阅读源码,有如下内容:

<!--
find rare characters in the mess below:
-->

<!--
......
......
......
-->

编写代码从中提取出字符串即可:

from urllib import request
from html.parser import HTMLParser

class HandleComment(HTMLParser):
    def handle_comment(self, data):
        for c in data:
            if c.isalnum() or c == ' ':
                print(c, end='')

        print()


url = 'http://www.pythonchallenge.com/pc/def/ocr.html'
response = request.urlopen(url)
content = response.read()
hc = HandleComment()
hc.feed(str(content, 'utf-8'))
hc.close()

最终获得字符串equality,替换掉问题URL中的ocr即得到最终链接。

相关文章

  • Python挑战:00~03关

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

  • The Python Challenge(3)

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

  • Python Challenge[3]

    [Level 3] Title: re One small letter, surrounded by EXACT...

  • Python挑战:04-05关

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

  • Python Challenge 第3关

    地址:http://www.pythonchallenge.com/pc/def/linkedlist.php

  • Python Challenge 第3关

    第3关 没看懂题目,大概意思是一个小写字母,两边是三个大写字母。页面内没有内容,应该跟上一题一样在源码中。果然,源...

  • The Python Challenge(5)

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

  • The Python Challenge(8)

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

  • The Python Challenge(9)

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

  • The Python Challenge(2)

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

网友评论

      本文标题:The Python Challenge(3)

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