豆瓣最受欢迎的影评爬虫(第一个爬虫撒花!)
来源:互联网 发布:卡洛斯实况巅峰数据 编辑:程序博客网 时间:2024/04/30 11:21
-- coding: utf-8 --
from bs4 import BeautifulSoup
import requests
import urllib
import codecs
import re
import json
urlnumber = 0
while urlnumber<60:
print type(urlnumber), urlnumber
url = ‘https://movie.douban.com/review/best/?start=%d’ % (urlnumber,)
html=urllib.urlopen(url)
soup=BeautifulSoup(html)
links = soup.find_all(“a”,class_=”j a_unfolder”)
i=1+urlnumber
for link in links:
new_url = link[‘href’]
new_html=urllib.urlopen(new_url)
newsoup=BeautifulSoup(new_html)
title=newsoup.find(“span”,property=”v:summary”)
a=title.get_text().encode(‘utf-8’) #转换成str
# print a
content=newsoup.find(“div”,property=”v:description”)
b=content.get_text().encode(‘utf-8’)
dict = {‘title’:a,’content’:b}
# print b
j = json.dumps(dict,ensure_ascii=False) #后面的参数是重点,json从此不再是编码,而是中文了
output=codecs.open(‘yingping/%d.json’%i,’w’)
output.writelines(j)
output.close()
i += 1
urlnumber += 10
- 豆瓣最受欢迎的影评爬虫(第一个爬虫撒花!)
- python爬虫(豆瓣影评)
- 我的第一个豆瓣短评爬虫
- 第三只爬虫-----豆瓣影评
- python爬虫实战:分析豆瓣中最新电影的影评
- Python 爬虫实战:分析豆瓣中最新电影的影评
- Python 爬虫实战:分析豆瓣中最新电影的影评(词云显示)
- Python 简单爬虫 豆瓣热门影评
- python爬虫实战:《星球大战》豆瓣影评分析
- 小菜鸟的第一个爬虫:豆瓣爬取电影信息
- Python3爬虫之六网页的初步分析【抓取豆瓣最新电影影评并用词云显示】
- (8)Python爬虫——爬取豆瓣影评数据
- python爬虫(豆瓣影评requests版并下载电影封面图片)
- 爬虫实践---Scrapy-豆瓣电影影评&深度爬取
- Python 爬虫实践:《战狼2》豆瓣影评分析
- Python 爬虫实践:《战狼2》豆瓣影评分析
- Python2.7 爬虫实践:豆瓣电影影评分析
- python爬虫爬取豆瓣top250电影影评
- linux下乱码问题
- Educational Codeforces Round 13
- 【C】文件读写操作
- 数组去重
- 【bzoj4568】【SCOI2016】【幸运数字】【树上倍增+线性基】
- 豆瓣最受欢迎的影评爬虫(第一个爬虫撒花!)
- 168. Excel Sheet Column Title
- Unity3D:Compate Shader
- bootstrap的日期选择器插件
- mycat是什么鬼?垂直切分?水平切分?
- centos安装Samba服务器
- Android开发用过的十大框架
- MIT Introduction to Algorithms Record-8
- 物流营销服务