# -*- coding: utf-8 -*-
import re, urllib, time
def kn(book):
url=''
while not url:
try:
kn1 = urllib.urlopen('http://flibusta.net/' + book)
url = kn1.geturl()
time.sleep(1)
print "get %s" % book
except: print "Can't get %s" % book
return url
if __name__ == '__main__':
conf = open('config.txt', 'r')
list_url = conf.readlines()
conf.close()
res = open('urls.txt','w')
for url in list_url:
print "Getting URL's from %s" % url.strip()
r = urllib.urlopen(url).read()
books = re.findall('', r)
books += re.findall('', r)
books = map(kn, books)
res.write('\n'.join(books)+'\n')
res.close()
raw_input('Press any key...')