zoukankan      html  css  js  c++  java
  • [解决方案] 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

  • 相关阅读:
    Python保留最后N个元素
    STL算法
    STL迭代器
    STL容器
    C++总结1
    牛客剑指Offer2
    Vue第一天
    UML
    Java继承和组合代码
    Java15后的sealed阻止继承滥用
  • 原文地址:https://www.cnblogs.com/hsp401/p/4483509.html
Copyright © 2011-2022 走看看