首页 > 代码库 > python_小爬虫
python_小爬虫
import urllib.request as requestimport urllib.parse as parseimport stringprint("""+++++++++++++++++++++++ name:cphmvp version: python3.3+++++++++++++++++=++++ """)def baidu_tieba(url, begin_page, end_page): for i in range(begin_page, end_page + 1): sName = str(i).zfill(5)+‘.html‘ print(‘正在下载第‘+str(i)+‘个页面, 并保存为‘+sName) m = request.urlopen(url+str(i)).read() with open(sName,‘wb‘) as file: file.write(m) file.close()if __name__ == "__main__": url = "http://tieba.baidu.com/p/" begin_page = 1 end_page = 3 baidu_tieba(url, begin_page, end_page)
python_小爬虫
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。