美文网首页
The Python Challenge(4)

The Python Challenge(4)

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

问题链接

问题链接如下:

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

答案链接

答案链接如下:

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

解题思路

根据页面提示:

One small letter, surrounded by EXACTLY three big bodyguards on each of its sides.

并结合页面源码中的内容,有如下代码:

from urllib import request
from html.parser import HTMLParser
import re

class HandleComment(HTMLParser):
    def handle_comment(self, data):
        ret = re.findall('[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]', data)
        print(''.join(ret))


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

输出结果如下:

linkedlist

替换原始URL中的equality,得到URL:http://www.pythonchallenge.com/pc/def/linkedlist.html,输入该URL到浏览器,显示字符串linkedlist.php,则最终获得答案链接: http://www.pythonchallenge.com/pc/def/linkedlist.php

相关文章

  • Python挑战:00~03关

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

  • The Python Challenge(4)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 根据页面提示: 并结合页面源码中的内容,有如下代码:...

  • Python Challenge[4]

    [Level 4] Title: follow the chain 页面中无有用的提示,查看源码,在注释中找到 u...

  • Python挑战:04-05关

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

  • The Python Challenge(5)

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

  • The Python Challenge(8)

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

  • The Python Challenge(9)

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

  • The Python Challenge(2)

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

  • The Python Challenge(3)

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

  • The Python Challenge(6)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 根据页面源码提示: python中发音类似的术语有p...

网友评论

      本文标题:The Python Challenge(4)

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