第三关的谜面是:
One small letter, surrounded by EXACTLY three big bodyguards on each of its sides.
大概意思就是每一个小写字母的两边都有且只有3个大写字母,也就是如oXXXaXXXo的形式中,a就是需要找出的小写字母。
同样从网页源码里找到目标文本,代码如下:
import urllib
import re
text = urllib.urlopen('http://www.pythonchallenge.com/pc/def/equality.html').read().split('<!--')[-1].replace('-->', '')
print "".join(re.findall('[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]', text))结果为:
linkedlist
替换URL后提示使用linkedlist.php,顺利进入下一关:)
=================分割线===================
这个方法挺有意思:
>>> import string
>>> code = """
... <copy and paste>
... """.replace("\n", "")
>>> word = ""
>>> for i in range(len(code) - 8):
... if [c for c in code[i:i+9] if c in string.lowercase] == [code[i], code[i+4], code[i+8]]:
... word += code[i+4]
...
>>> word
'linkedlist'
本文探讨了解决复杂网页谜题的过程,通过利用正则表达式和字符串操作,成功从源代码中提取关键信息。具体展示了如何在Python环境下进行网页爬取和解析,最终得出解为'linkedlist',并引导读者前往下一个挑战。
2226

被折叠的 条评论
为什么被折叠?



