Ross Wan's World!

Python, Ajax, PHP and Linux.

The Python Challenge Lv.4

Posted by Ross Wan 于 2011/08/22

Lv.4

打开第4关的网址,得到如下内容:

linkedlist.php

将网址改为 http://www.pythonchallenge.com/pc/def/linkedlist.php, 再打开,终于进入到第4关,看到一张”木偶锯木”的图片,点击它,进入到 http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345 页面显示:

and the next nothing is 44827

根据页面提示,将网址最后的nothing参数改为 44827, 打开http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=44827, 又得到提示:

and the next nothing is 45439

再改网址的nothing参数吧, http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=45439,这次终于得到稍有不同的提示了:

Your hands are getting tired and the next nothing is 94485

这算是安慰的说话吗?想一想,这样重复又重复的工作,不正是程序应做的事情吗?!

#!bin/python3
# coding=utf8

import re, urllib.request

if __name__ == '__main__':
    nothing = '94485'
    while 1:
        response = urllib.request.urlopen('http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=%s' % nothing)
        content = response.read().decode('ascii')
        response.close()
        print(content)
        match_obj = re.match(r'^and the next nothing is (\d+)', content)
        if match_obj:
            nothing = match_obj.groups()[0]
        else:
            break

经过若干次抓取页面之后停住了,提示:

and the next nothing is 16044
Yes. Divide by two and keep going.

意思就是除2再继续,晕~~将上面脚本的 nothing 改为’8022’再次运行.不久,页面又停住了:

and the next nothing is 82682
There maybe misleading numbers in the
text. One example is 82683. Look only for the next nothing and the next nothing
is 63579

提示错误,要从63579再次运行,再次晕倒.那再将上面的脚本中的nothing改为’63579′

再次运行…

and the next nothing is 66831

peak.html

皇天不负有心人,都不知运行多长时间了,终于显示下一关的关键字,真是想哭呀~~~Lv.5:http://www.pythonchallenge.com/pc/def/peak.html

Have fun :~?

Advertisements

一条回应 to “The Python Challenge Lv.4”

  1. […] The Python Challenge Lv.4 […]

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

 
%d 博主赞过: