字典枚举某网站游戏地址

代码:

#coding=utf8
import urllib2

word_file = open("words.txt","r")
url_file = open("nazo.html","a")
while True:
    line = word_file.readline()
    if not line:
        break
    line = line.strip()
    
    url_list = ['http://cafebabe.cc/nazo/basic/','http://cafebabe.cc/nazo/medium/','http://cafebabe.cc/nazo/']
    
    for url in url_list:
        try:
            url = url + line + '.html'
            page = urllib2.urlopen(url)
            print 'success -> ', url
            url_file.write(url+"
")
        except Exception,ex:
            print '
failed -> ',line,
            pass
word_file.close()
url_file.close()
原文地址:https://www.cnblogs.com/arbboter/p/4573244.html