.+?
')
s1=re1.findall(html)
s2=re2.findall(html)
if len(s1)>0 and len(s2)>0:
name=s1[0].replace('''','')
content=content.replace('
','')
content=content.replace('','\n\t') content = content.replace(' ', '') else: name=' ' content=' ' return name,content def write_novel(i,file1): file1.writelines('\n\r') s=383+i; html = gethtml(url1 % s) name,content = get_name_content(html) file1.writelines(name) file1.writelines('\n\t') file1.writelines(content) file1.writelines('\n\n\n') file1=file('间客.txt','w+') [write_novel(i,file1) for i in range(50)] file1.close()