#!/usr/bin/env python
# coding: utf-8
# In[1]:
from selenium import webdriver
import time
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import os
from bs4 import BeautifulSoup
import numpy as np
import pandas as pd
from pandas import DataFrame
import re
import jieba
import jieba.analyse as anls
from wordcloud import WordCloud
from wordcloud import ImageColorGenerator
from PIL import Image
import matplotlib.pyplot as plt
#读取的文本存入本地文件
storage_file_path=r"E:\jd_comments.txt"
if os.path.exists(storage_file_path):
os.remove(storage_file_path)
url0="https://item.jd.com/28501887051.html#comment"
#url0="https://item.jd.com/34378572773.html#comment"
url=input("请输入您要读取评论的网页地址:ENTER 默认"+url0)
if url=="":
url=url0
max_page_number=input("请输入需要读取多少页评论:")
max_page_number=int(max_page_number)
print("好的,即将为你读取",max_page_number,"页评论")
driver=webdriver.Chrome()
driver.get(url)
#寻找到评论按钮并点击,翻开评论
try:
WebDriverWait(driver,10).un