http://www.pythonchallenge.com/pc/def/linkedlist.php
查看页面源代码或者点击图片
http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345
and the next nothing is 44827
本题将页面中的数字代替url中nothing的值
python:
import re
import requests
burl='http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='
new=u'12345'
res=re.compile(r'and the next nothing is (d+)')
while 1:
gurl=requests.get(burl+str(new))
content=gurl.text
print content
try:
value=re.findall(res,gurl.text)[0]
new,old=value,new
except:
status=raw_input('continue or break(c/b):')
if status=='c':
rnew=raw_input('input the next nothing is number(default:%s/2)):' % new)
if not rnew:
new = int(new)/2
else:
new = int(rnew)
else:
break
最后得到:peak.html
http://www.pythonchallenge.com/pc/def/peak.html