如题,是一个链表,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 = ""
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)

【PythonChallenge】Level 4的更多相关文章

  1. 【PythonChallenge】Level 3

    题目为正则表达式,需要注意EXACTLY的含义,即AAAAxBBB中x不满足条件,但aAAAxBBBa却满足条件.使用perl解决此题,利用s///替换字母,循环读取整个源码文件,结果为linkedl ...

  2. 【PythonChallenge】Level 5

    题目主要找发声类似于Peak Hell的Python模块,查了一下手册pickle已经是最像的了.看了一下源代码,发现panner.p.如同发现了新大陆,拷贝内容.使用pickle解答.答案为chan ...

  3. 【XSS-labs】Level 1-5

    写在前面: 这个闯关游戏旨在理解XSS的原理并运用各种姿势绕过对于XSS攻击的过滤和限制. 这个练习只要弹出弹框即可过关 ,每一关我也会附上payload和源代码的解析 Level 1 观察源码 &l ...

  4. 【XSS-labs】level 16-20

    Level 16 查看源码:发现 空格 / 和script都被转义了. 用img标签的onerror事件(在加载外部文档或图片出错后触发),空格用%0a绕过,  payload如下: <img% ...

  5. 【XSS-labs】Level 11-15

    Level 11 和level 10 差不多的页面,传参后查看页面源代码:依旧是第3个可以正常传参. 尝试level 10 的payload 发现 " 被实体化 可以打开控制台将第三个inp ...

  6. 【XSS-labs】level 6-10

    Level 6 查看源码:对URL中的传参进行了HTML实体化转义,搜索框中的值对 src\onxxxxx\data\href进行了限制. 采用大小写绕过,在搜索框输入payload,注意闭合inpu ...

  7. 【转】H264视频编码级别说明profile level Encoder

    版权声明:本文为博主原创文章,未经博主允许不得转载. 首先要阐明所谓的AVC其实就是H.264标准,是由ITU-T和ISO/IEC组成的联合视频组(JVT,Joint Video Team)一起开发的 ...

  8. 【Python】脚本运行报错:IndentationError: unindent does not match any outer indentation level

    [问题] 一个python脚本,本来都运行好好的,然后写了几行代码,而且也都确保每行都对齐了,但是运行的时候,却出现语法错误: IndentationError: unindent does not ...

  9. 【LeetCode-面试算法经典-Java实现】【107-Binary Tree Level Order Traversal II(二叉树层序遍历II)】

    [107-Binary Tree Level Order Traversal II(二叉树层序遍历II)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Given a ...

随机推荐

  1. Mysql 冷备份批处理

    @Rem Generate today date @echo wscript.echo dateadd("d",0,date)>GetOldDate.vbs @for /f ...

  2. jfinal取消默认跳转到view.jsp页面的方法

    今天为了在一个列表中添加一个删除的方法,直接在方法里面谢了一个dao.del();方法,但是调用的时候却出现404错误. 然后就写了一句下面的代码 redirect("/api/listMe ...

  3. 基于微软EnterpriseLib的框架(一)

    1.框架模型无ORM,重点在数据库建模设计与UI框架设计上 2.多数据库支持(Enterprise Lib 默认仅支持SqlServer和Oracle,需自己扩展才能支持其他数据库,本文已扩展SQLi ...

  4. 暑假集训(2)第五弹 ----- Who's in the Middle(poj2388)

    G - Who's in the Middle Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32 ...

  5. error RC1205: invalid code page

    Get followings error and warnings when building project: error RC1205: invalid code pagewarning C400 ...

  6. ImageButton如何让图片按比例缩放不被拉伸

    了解 在安卓的界面XML中,ImageButton有这样一个属性android:scaleType,他干嘛的? ImageView的Scaletype决定了图片在View上显示时的样子,如进行何种比例 ...

  7. 程序员面试题精选100题(38)-输出1到最大的N位数[算法]

    作者:何海涛 出处:http://zhedahht.blog.163.com/ 题目:输入数字n,按顺序输出从1最大的n位10进制数.比如输入3,则输出1.2.3一直到最大的3位数即999. 分析:这 ...

  8. win7下 mysql主从配置实现

    win7下学习 mysql主从复制 一.环境: 主服务器(master):192.168.1.23 mysql版本:5.5 从服务器(slave):192.168.1.24 mysql版本:5.5   ...

  9. Control character in cookie value, consider BASE64 encoding your value , java操作cookie遇到中文会报错的解决方案

    项目当中用到cookie保存中文,但是会报如下错误: Control character in cookie value, consider BASE64 encoding your value 大概 ...

  10. iis7以上版本权限控制

    IIS7.5中(仅win7,win2008 SP2,win2008 R2支持),应用程序池的运行帐号,除了指定为LocalService,LocalSystem,NetWorkService这三种基本 ...