[解决方案] pythonchallenge level 4

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

上一篇:【BZOJ-1924】所驼门王的宝藏 Tarjan缩点(+拓扑排序) + 拓扑图DP


下一篇:arcgis api for js入门开发系列二十打印地图的那些事