python简单的爬虫

def baidu_tieba(url,begin_page,end_page):
    for i in range(begin_page, end_page+1):
        sName = string.zfill(i,5) + '.html'
        print ('ing %d') %i
        f = open(sName,'w+')
        m = urllib2.urlopen(url + str(i)).read()       #接受反馈信息 并且读取反馈内容
        f.write(m) 
        f.close()
baidu_tieba('http://tieba.baidu.com/p/4500499977',1,5)

 

posted @ 2017-01-24 10:07  webbky  阅读(195)  评论(0编辑  收藏  举报