zoukankan      html  css  js  c++  java
  • pythonchallenge 闯关游戏

    Level 4:

    Level 4

    此关有点抽象,打开PAGE SOURCE,查看用绿色字体标注的部分,会发现提示所用模块:URLLIB,prompt 如下:

    <!-- urllib may help. DON'T TRY ALL NOTHINGS, since it will never end. 400 times is more than enough. -->

    先双击图片,会发现跳转到一个新PAGE,注意PAGE CONTENT提示:"and the next nothing is xxxxx",题目的要求是将后面的NOTHING(数字部分)提取出来,作为URL 上的NOTHING值,大概重复400次。如果手工改,达不到题目要求。这就涉及需使用URLLIB模块进行循环操作。示例代码如下:

    import urllib,re
    url
    ="http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing="
    desNum
    ="12345"
    for i in range(400):
    content
    =urllib.urlopen(url+desNum).read()
    desNum
    ="".join(re.findall(r"nothing is (\d+)",content))

    ifnot desNum:
    print content
    break

    print"next nothing:",desNum

    问题点:此程序循环到NOTHING=16044时content 会显示出一行英文:Yes.Divide by two and keep going.大体意思是除2继续循环,此时需将程序中的desNum初始化为8022(16044/2=8022),然后继续运行程序。等程序终止时,会找到我们所需要的答案:****.html.答案我就不说了,呵呵。

    PS: 解完题,感觉很爽,进一步了解了URLLIB的运用。但也意识到知识的薄弱(做的时间比较长),还得继续努力!

     
  • 相关阅读:
    在线安装eclipse中html/jsp/xml editor插件 eclipseeditor
    webstorm 破解方式
    c# 下实现ping 命令操作
    Newtonsoft 序列化和反序列化特殊处理
    jquery 页面滚动到底部自动加载插件集合
    Bootstrap 模态对话框只加载一次 remote 数据的解决办法
    CSS文本溢出处理
    js 操作table
    Js 冒泡事件阻止
    WCF4.0 –- RESTful WCF Services
  • 原文地址:https://www.cnblogs.com/ballwql/p/2117607.html
Copyright © 2011-2022 走看看