爬取小说文件(第二天)

1、使用python将文件下载下来

open_url = urllib2.urlopen(xiaoshuo_down_urls)
data = open_url.read()
with open(xiaoshuo_name+'.zip',"wb") as code:
    code.write(data)

下载下来的名称会报错,出现乱码

经过试验,在第一天的代码中直接使用name就可以了

出错原因:使用正则表达式,name直接返回的就是小说的具体名字了,如果在这里使用的时xiaoshuo_name,那么输出的就是“utf-8”的格式了,不是汉字了,所以输出的文件名称就出现了错误。

posted @ 2016-01-20 23:03  kingrain  阅读(88)  评论(0)    收藏  举报