python抓取几大票房统计系统数据的之猫眼电影
来源:互联网 发布:淘宝司马zm17 编辑:程序博客网 时间:2024/05/18 01:00
# coding=utf-8import reimport urllib2import chardetclass Maoyandianying_01: dataT_h2 = [] dx = [] def downAndparse(self,url): response_1 = urllib2.urlopen(url).read() # 解决乱码问题 mychar = chardet.detect(response_1) bianma = mychar['encoding'] print bianma if bianma == 'utf-8' or bianma == 'UTF-8': response = response_1 print 'xx' else: response = response_1.decode('gb2312', 'ignore').encode('utf-8') self.parseB(response) self.parseI(response) dataT_fileName = [] def parseB(self,response): h = re.findall(r'<b>[^<i class="cs gsBlur">].*?</b>', response, re.M) for i in set(h): objM = re.match(r'<b>(.*?)</b>', i, re.M) if objM: # print objM.group() # print objM.group(1) self.dataT_fileName.append(objM.group(1)) def parseI(self,response): h2 = re.findall(r'<i class="cs gsBlur">.*</i>',response,re.M) for i in h2: objM = re.match(r'<i class="cs gsBlur">(.*?)</i>',i,re.M) if objM: self.dataT_h2.append(objM.group(1)) for ii in range(1,self.dataT_h2.__len__()): if ii%5 == 0: self.dx.append(ii) # print ii df = [] def sendtodb(self): for i in self.dataT_fileName: print i print '------' dv = [self.dataT_h2[1],self.dataT_h2[2],self.dataT_h2[3],self.dataT_h2[4],self.dataT_h2[5]] self.df.append(dv) print '=========' print self.dx print self.dataT_h2.__len__() for iii in range(len(self.dx)-1): dn = [self.dataT_h2[self.dx[iii] + 1], self.dataT_h2[self.dx[iii] + 2], self.dataT_h2[self.dx[iii] + 3], self.dataT_h2[self.dx[iii] + 4],self.dataT_h2[self.dx[iii] + 5]] self.df.append(dn) print len(self.dataT_fileName) print self.df.__len__() for i in range(self.df.__len__()): self.df[i].append(self.dataT_fileName[i])if __name__ == '__main__': url = 'https://piaofang.maoyan.com/?ver=normal' maoyan = Maoyandianying_01() maoyan.downAndparse(url) maoyan.sendtodb() print len(maoyan.df) for i in maoyan.df: print i
阅读全文
0 0
- python抓取几大票房统计系统数据的之猫眼电影
- python抓取几大票房统计系统数据的之艺恩电影数据
- python抓取几大票房统计系统数据的之专资办票房数据库
- python抓取猫眼电影top100
- 猫眼电影 票房爬取
- python 爬虫抓取猫眼电影 top100 源码
- 猫眼发布电影大数据报告:大数据时代的电影消费洞察
- python爬虫实战:抓取猫眼电影TOP100存放到MongoDB中
- python3的爬虫抓取猫眼电影的信息(requests+正则表达式)
- Python爬取猫眼电影TOP100
- 三种方法抓取猫眼电影top100信息
- python3爬虫之猫眼电影Toop100获取
- 大数据分析进阶之python财经数据抓取
- [Python]抓取豆瓣电影列表的标题
- python抓取豆瓣电影
- Python爬虫-爬取猫眼电影Top100榜单
- 爬取猫眼电影专业版实时数据排行榜
- 《后会无期》票房赶超《小时代3》 大数据解读韩寒VS四娘之争
- CentOS764位安装ELK
- FX3/CX3 I2C error
- Linux下JDK、Tomcat的安装及配置
- 数据库小节
- JavaWeb项目中文乱码问题
- python抓取几大票房统计系统数据的之猫眼电影
- 织梦标签调用代码。
- 如何在 Azure 中的 Linux 经典虚拟机上设置终结点
- 搜集的86道hadoop面试真题
- 关于字符串的一些整理
- ComboBox控件自绘操作
- STN系列之人脸检测
- Git 使用篇二:搭建远程服务器
- LeetCode 378. Kth Smallest Element in a Sorted Matrix (Medium)