# 抓取用户名
#'review-author-name'是html语言中<div class>对应的class name
authors = browser.find_elements_by_class_name('review-author-name')
#获取该tag所对应的文本
lstAuthors = [authors.text for i in range(len(authors))]
1
2
3
4
5
# 抓取点赞数
stars = browser.find_elements_by_class_name('review-stars')
#点赞数无法从'review-stars'这tag对应的text中获取,但据观察可知,其子块中icon-star-light的数目就是点赞的星星数
lstStars = [len(stars.find_elements_by_class_name(' icon-star-light')) for i in range(len(stars))]
1
2
3
4
#抓取评论内容
reviews = browser.find_elements_by_class_name('review-content')
lstReviews = [reviews.text for i in range(len
1
2
3
#抓取评论时间
review_time = browser.find_elements_by_class_name('review-author-time')
lstReviewTime = [review_time.text for i in range(len(review_time))]
1
2
3
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import pandas as pd
from datetime import datetime
import numpy as np
import time
import os
# 抓取用户名
#'review-author-name'是html语言中<div class>对应的class name
authors = browser.find_elements_by_class_name('review-author-name')
#获取该tag所对应的文本
lstAuthors = [authors.text for i in range(len(authors))]
# 抓取点赞数
stars = browser.find_elements_by_class_name('review-stars')
#点赞数无法从'review-stars'这tag对应的text中获取,但据观察可知,其子块中icon-star-light的数目就是点赞的星星数
lstStars = [len(stars.find_elements_by_class_name(' icon-star-light')) for i in range(len(stars))]
#抓取评论内容
reviews = browser.find_elements_by_class_name('review-content')
lstReviews = [reviews.text for i in range(len
#抓取评论时间
review_time = browser.find_elements_by_class_name('review-author-time')
lstReviewTime = [review_time.text for i in range(len(review_time))]