第四关地址:[http://www.pythonchallenge.com/pc/def/linkedlist.php](http://www.pythonchallenge.com/pc/def/linkedlist.php)
![](https://img.kancloud.cn/d0/a2/d0a291b8d21b690c456c71e32ade6e8b_383x542.png)<br><br>
解题过程:首先图片是一个链接,可以点击。源代码中也有一段文字提示
```
urllib may help. DON'T TRY ALL NOTHINGS, since it will never end. 400 times is more than enough.
```
**百度翻译:urllib可能有帮助。不要什么都试,因为它永远不会结束。400次就足够了。**
![](https://img.kancloud.cn/22/5c/225cb1485c97705934ececab04c52e81_1160x506.png)
<br><br><br>
多次点击图片
**第一次点击:**![](https://img.kancloud.cn/a0/d5/a0d54365c3e2a136c2e8cfc371a9a970_615x143.png)
将链接中的12345换位44827继续访问
![](https://img.kancloud.cn/b8/fb/b8fb7c2f3660b5c81b65d3dafb3117a1_587x123.png)
在继续一次:
![](https://img.kancloud.cn/93/d6/93d66035da8f4bcd910f009792388540_608x132.png)
到现在,大概该明白源代码中提示的意思了!
```
# 目标获取网页内容 "and the next nothing is 44827"中的44827(倒数5位数),将其作为域名访问,一直循环
# 大概需要用到urllib库的知识
import urllib.request
str_index = '72156' # 初始值是12345,下面两个是会遇到的特殊值
# str_index = '8022' # 这个特殊值需要自己手动输入
# str_index = '63579' # There maybe misleading numbers in the text. One example is 82683. Look only for the next nothing and the next nothing is 63579,你可以通过从右边开始搜索is,或者搜索'and the next nothing is'都是可以跳过这句的
for i in range(100): # 次数这里可以设置更大数字,100是随缘写的,实际大概总共需要循环四,五百次吧,直接写while TRUE应该也是可以的
url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=' + str_index # 下一次该要访问的url
print(url)
response = urllib.request.urlopen(url) # 请求站点获得一个HTTPResponse对象
str_text = response.read().decode('utf-8') # 返回网页内容,字符串
print(str_text)
index = str_text.find('is') # 寻找is出现的位置,便于后面获取nothing值
print('nothing值的长度:' + str(len(str_text) - (index + 3)))
if (len(str_text) - (index + 3)) == 5:
str_index = str_text[index+3] + str_text[index+4] + str_text[index+5] + str_text[index+6] + str_text[index+7] # nothing值
elif (len(str_text) - (index + 3)) == 4:
str_index = str_text[index + 3] + str_text[index + 4] + str_text[index + 5] + str_text[index + 6] # nothing值
elif (len(str_text) - (index + 3)) == 3:
str_index = str_text[index + 3] + str_text[index + 4] + str_text[index + 5] # nothing值
```
最终经过好几百此的循环,见证到结果!
![](https://img.kancloud.cn/eb/92/eb924752f63d0244c99e548d4e2f0ad6_544x313.png)
**中间过程中,会出现一些特殊值,需要你自己重新输入nothing值继续循环!**
**下面是特殊值的截图!**
![](https://img.kancloud.cn/f7/f5/f7f58d7f2e727d968963e74581aced37_694x162.png)
![](https://img.kancloud.cn/0a/88/0a88f8bf9164247f30dc2bf9d70afacb_1011x154.png)