Python抓取京东图书评论数据
来源:中文源码网 浏览: 次 日期:2018年9月2日
【下载文档: Python抓取京东图书评论数据.txt 】
(友情提示:右键点上行txt文档名->目标另存为)
Python抓取京东图书评论数据 京东图书评论有非常丰富的信息,这里面就包含了购买日期、书名、作者、好评、中评、差评等等。以购买日期为例,使用Python + Mysql的搭配进行实现,程序不大,才100行。相关的解释我都在程序里加注了:
from selenium import webdriver
from bs4 import BeautifulSoup
import re
import win32com.client
import threading,time
import MySQLdb
def mydebug():
driver.quit()
exit(0)
def catchDate(s):
"""页面数据提取"""
soup = BeautifulSoup(s)
z = []
global nowtimes
m = soup.findAll("div",class_="date-buy")
for obj in m:
try:
tmp = obj.find('br').contents
except Exception, e:
continue
if(tmp !=