neihan8段子爬取
来源:互联网 发布:淘宝客手机可以开通吗 编辑:程序博客网 时间:2024/05/21 09:20
# coding:utf-8import urllib2import reimport timeclass Spider(object): def __init(self): pass def loadPage(self): startNum = int(raw_input("请输入起始页号:")) endNum = int(raw_input("请输入结束页号:")) headers = { "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" } for num in range(startNum, endNum + 1): if num == 1: url = "http://www.neihan8.com/article/index.html" else: url = "http://www.neihan8.com/article/index_%s.html"%str(num) print url request = urllib2.Request(url,headers = headers) response = urllib2.urlopen(request) #print response.read() html = response.read() pattern = re.compile('<div\sclass="desc">(.*?)</div>',re.S) content_list = pattern.findall(html) self.writePage(content_list) def writePage(self,content_list): with open("duanzi.txt","a") as f: for content in content_list: f.write(content+"\r\n\r\n")if __name__ == "__main__": Spider().loadPage()
阅读全文
0 0
- neihan8段子爬取
- 爬取网站段子
- 爬取糗事百科段子
- python爬虫爬取段子
- 糗事百科段子爬取
- 【网络爬虫】爬取糗事百科段子
- 利用Scrapy爬取糗事百科段子
- python 爬虫 爬取糗事百科段子
- [Scrapy]爬取糗事百科段子
- 爬取糗事百科,朗读段子
- Python爬虫 爬取糗事百科段子
- 【爬虫】爬取煎蛋上的段子
- Python爬虫爬取糗事百科段子
- 爬取糗事百科的段子Demo
- python爬取糗事百科段子
- Python爬虫 爬取糗事百科段子
- Python爬虫实战一之爬取糗事百科段子
- pythpn学习の爬虫爬取糗事百科热门段子
- 高层管理者(笔记)——任务、组织与战略
- 在面板上移动的字
- Mysql数据库备份(一)------数据库备份和表备份
- form设置margin:0px auto不生效
- 【单链表经典面试题解析一】从尾到头打印单链表
- neihan8段子爬取
- 11 SMO优化算法
- Ubuntu下anaconda3.5搭建tensorflow
- 删除kafka的topic
- ST表模板
- leetcode 698. Partition to K Equal Sum Subsets(记忆化搜索/状压dp)
- 对线性回归、逻辑回归、各种回归的概念学习
- 降维-多维尺度法(MDS)
- 机器学习之朴素贝叶斯法(基于西瓜数据3.0的算法实现)