第3關(guān)比較難懂,題目:

第3關(guān)題目.png
下面有一行英文:“One small letter, surrounded by EXACTLY three big bodyguards on each of its sides.”
剛剛闖到第三關(guān)就感覺題目開始有難度了??
研究了半天,大概意思是,找到兩邊都是三個大寫字母的小寫字母,格式:xXXXxXXXx。于是按下F12,果然在源代碼中又找到一大段字符串:

于是還要使用urllib.requests,配合re。
代碼:
import urllib.request
import re
url = 'http://www.pythonchallenge.com/pc/def/equality.html'
req = urllib.request.urlopen(url)
body = req.read()
body = body.decode('utf8')
req.close()
regex = re.compile(r'[^A-Z][A-Z]{3}[a-z][A-Z]{3}[^A-Z]')
code = re.findall(regex, body)
result=''
for i in code:
result = result+(i[4])
print(result)
得到結(jié)果linkedlist,下一關(guān)鏈接為http://www.pythonchallenge.com/pc/def/linkedlist.html
這里有個小陷阱,打開下一關(guān)鏈接,網(wǎng)頁如下:

網(wǎng)頁上沒有其他內(nèi)容,我一度懷疑是我程序有問題。后來琢磨半天,才知道下一關(guān)正確的鏈接是:http://www.pythonchallenge.com/pc/def/linkedlist.php