Python小例子

import urllib.request as request
import urllib.parse as parse
import string
print("""
+++++++++++++++++++++++
   数据挖掘哪家强?
   北京朝阳找龙道!
+++++++++++++++++=++++
     """)
def baidu_tieba(url, begin_page, end_page):
    for i in range(begin_page, end_page + 1):
        #sName = 'E:/Python_test/'+str(i).zfill(5)+'.html'
        m = request.urlopen(url+str(i)+'.html').read()
        print('源码:'+str(m))
        #sName = 'E:/Python_test/'+str(i)+'.html'
        #print('正在下载第'+str(i)+'个页面, 并保存为'+sName)
        #写进文件
        #with open(sName,'wb') as file:
            #file.write(m)
        #file.close()
if __name__ == "__main__":
    url = "http://www.nipic.com/show/"
    begin_page = 10986746
    end_page = 10986748
    baidu_tieba(url, begin_page, end_page)

 

posted @ 2014-11-06 16:00  GisClub  阅读(220)  评论(0编辑  收藏  举报