pythonchallenge_level4

简介: pythonchallenge各关解题

level4

地址:http://www.pythonchallenge.com/pc/def/linkedlist.php
源码:git@code.aliyun.com:qianlizhixing12/PythonChallenge.git。
问题:在页面源码中找出数字替换URL。

#!/usr/bin/env python3
# -*- coding:UTF-8 -*-

# Level 4

import urllib.request
import re

def fun(sid):
    url = "http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=" + sid
    response = urllib.request.urlopen(url)
    body = response.read()
    response.close
    
    body = body.decode("utf8")
    nid = body.split(" ")[-1]
    
    if nid.isdigit():
            return fun(nid)
    elif body == "Yes. Divide by two and keep going.":
        sid = str(int(sid) / 2)
        return fun(sid)
    else:
        return body

if __name__ == "__main__":
    print("Level 4:", fun("12345"))
相关文章
|
5月前
[WUSTCTF 2020]level3
[WUSTCTF 2020]level3
36 0
|
开发框架 Java API
J2EE Specification Level
J2EE Specification Level
118 0
0227show all segment level statistics
[20180227]show all segment level statistics.txt https://orainternals.wordpress.com/2013/06/12/dude-where-is-my-redo/ REM Author : Ri...
1020 1
|
关系型数据库 测试技术 Oracle
[20180102]statistics_level=BASIC.txt
[20180102]statistics_level=BASIC.txt --//一个测试环境不知道谁设置statistics_level=BASIC,导致重启出现错误,自己在测试环境模拟看看: SYS@book> create pfile='/tmp/@.
1259 0
|
Python
pythonchallenge_level3
pythonchallenge各关解题
1129 0
|
Python
pythonchallenge_level10
pythonchallenge各关解题
1260 0
|
Python
pythonchallenge_level6
pythonchallenge各关解题
1139 0