首页 > 代码库 > Python小例子

Python小例子

import urllib.request as requestimport urllib.parse as parseimport stringprint("""+++++++++++++++++++++++   数据挖掘哪家强?   北京朝阳找龙道!+++++++++++++++++=++++     """)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)

 

Python小例子