zoukankan      html  css  js  c++  java
  • 【PythonChallenge】Level 4

    如题,是一个链表,N多数据,其中还有其它操作,比较麻烦,也是刚学python网络编程。对于Perl的RE很熟悉,还没有学python的,还是啃手册吧。
    其中在读出16044时,并没有找到匹配项,如下图所示:

    意思是除2,因此将8022作为参数,继续跑。又跑了段时间,跑到82682时,内容如下:
    There maybe misleading numbers in the text. One example is 82683. Look only for the next nothing and the next nothing is 63579。
    真是万恶啊。最开始没理解,以为是跑错了,才发现原来前面的数字是误导,因此使用re.search。或者直接将63579作为参数。最终得到结果:peak.html


    程序如下:

    from urllib.error import URLError, HTTPError
    import urllib.request
    import urllib.parse
    import re
    
    base = "http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing="
    tmp = "12345"
    pattern = re.compile(r"D+(d+$)")
    
    try:
        while True :
            url = base+tmp
            s = urllib.request.urlopen(url)
            code = s.read().decode('utf-8')
            s.close()
            nums = pattern.search(code);
            if nums == None:
                break
            else :
                tmp = nums.group(1)
                print (tmp)
                
    except HTTPError as e:
        print ('Error Code: ', e.code)
    except URLError as e:
        print ('Reason: ', e.reason)
        
    print("Final word is ", code)
    print(nums)
  • 相关阅读:
    bzoj 2763: [JLOI2011]飞行路线
    bzoj 2761: [JLOI2011]不重复数字
    bzoj 2744: [HEOI2012]朋友圈
    bzoj 2743: [HEOI2012]采花
    bzoj 2730: [HNOI2012]矿场搭建
    bzoj 2705: [SDOI2012]Longge的问题
    抗DDOS攻击
    kali安装后配置
    Kali更新源,亲测目前可用的源
    kali安装及配置ssr客户端
  • 原文地址:https://www.cnblogs.com/bombe1013/p/3581406.html
Copyright © 2011-2022 走看看