地址: http://www.pythonchallenge.com/pc/def/channel.html
题目只有一幅画, 有一个PayPal的按钮,也没有什么多余的提示. 查看page code,似乎也没有什么太有用的提示. 比较引起注意的是这样一句注释:
<html> <!-- <-- zip -->
仍然不是太明白. 呵,还是想象力不足够丰富.只能是google看了一下提示.然后发现了原来zip的提示是要把url改为www.pythonchallenge.com/pc/def/channel.zip 可以下载到一个zip 文件.
下载完成,解压缩, 会出现一堆的txt文件.随便打开:
Next nothing is 83831
是不是很眼熟啊?估计就是照着这个数字去找下一个文件.直到最后得到一个数
跟之前的那道题有一点区别的是, 得到的这个数是下一个文件的名字.
def getNextThing(str):
strSplite = str.split()
try:
nextNumber = strSplite[3]
print nextNumber
return nextNumber
except:
print str
return 0;
def readFile(fn):
fd = open(fn)
next = getNextThing(fd.read())
fd.close()
return next
folderPath = 'C:/channel'
fileName = '29'
counter = 3000
while counter!=0:
tmp = readFile(folderPath+'/'+fileName+'.txt')
if tmp != 0:
fileName = tmp
counter = counter - 1
else:
break
最终输出:
Collect the comments.
这必然不是正确的答案.重新查了一遍zip文件解压缩后的文件夹,发现有个文件名为readme.打开后发现真正有用的提示:
welcome to my zipped list.
hint1: start from 90052
hint2: answer is inside the zip
重点在于提示2. inside the zip是什么意思呢? 查了一下zipinfo类, 有comment成员. 于是读取出所有的comment的信息. 然后打印出,代码重新写后如下:
import zipfile
def getNextThing(str):
strSplite = str.split()
try:
nextNumber = strSplite[3]
print nextNumber
return nextNumber
except:
print str
return 0;
def readFile(fn):
fd = open(fn)
next = getNextThing(fd.read())
fd.close()
return next
folderPath = 'C:/channel'
fileName = '90052'
zipfd=zipfile.ZipFile('C:/channel.zip')
colletCom = ''
counter = 3000
while counter!=0:
tmp = readFile(folderPath+'/'+fileName+'.txt')
comment = zipfd.getinfo(fileName+'.txt').comment
colletCom += comment
if tmp != 0:
fileName = tmp
counter = counter - 1
else:
print colletCom
break
输出结果
Collect the comments.
****************************************************************
****************************************************************
** **
** OO OO XX YYYY GG GG EEEEEE NN NN **
** OO OO XXXXXX YYYYYY GG GG EEEEEE NN NN **
** OO OO XXX XXX YYY YY GG GG EE NN NN **
** OOOOOOOO XX XX YY GGG EEEEE NNNN **
** OOOOOOOO XX XX YY GGG EEEEE NN **
** OO OO XXX XXX YYY YY GG GG EE NN **
** OO OO XXXXXX YYYYYY GG GG EEEEEE NN **
** OO OO XX YYYY GG GG EEEEEE NN **
** **
****************************************************************
**************************************************************
按照之前的经验是输入hockey, 可是改变URL 后得到的是:
it's in the air. look at the letters.
好吧,又被欺骗了,输入所用到的字母: oxygen
得到了:http://www.pythonchallenge.com/pc/def/oxygen.html 这是最终的答案了