用户反馈自动分类程序
Posted bingna
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用户反馈自动分类程序相关的知识,希望对你有一定的参考价值。
1.安装Python和PyCharm,
代码如下
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
import time, datetime
start = datetime.datetime.now()
driver = webdriver.Chrome()
driver.maximize_window() # 最大化浏览器
driver.implicitly_wait(5) # 设置隐式时间等待
driver.get("http://XXXXXX")#修改需要执行程序的网站首页地址
js = "document.getElementById(‘start_date‘).removeAttribute(‘readonly‘)" # 去掉前端的readonly
driver.execute_script(js)
driver.find_element_by_id("start_date").send_keys(time.strftime("2019-08-27")) # 输入日期
js = "document.getElementById(‘end_date‘).removeAttribute(‘readonly‘)"
driver.execute_script(js)
driver.find_element_by_id("end_date").send_keys(time.strftime("2019-09-02")) # 获取当前日期time.strftime("%Y/%m/%d")
# driver.find_element_by_id("end_date").send_keys(time.strftime("2019-06-13")) # 获取当前日期time.strftime("%Y/%m/%d")
driver.find_element_by_id("filter_feeds_button").click()
driver.find_element_by_name("feedTable_length").send_keys("100")
WebDriverWait(driver, 25, 1).until(EC.presence_of_element_located((By.XPATH,
‘// *[ @ id = "feedTable"] / tbody / tr[1] / td[8] / div / button‘)))
# 获取页数
a = driver.find_element_by_xpath(‘//*[@id="feedTable_paginate"]/span/a[last()]‘).text
x = 0
y = 0
exit_flag = True
# 键词的数组
yinsi = ["隐私", "私隐", "不想别人看", "隱私", "稳私", "泄露", "瘾私", ]
turnOff = ["关闭", "关掉", "不想要这个功能"]
sex = ["色情", "低俗"]
title = ["标题党", "文不对题", "张冠李戴", "标题与内容不符", "雷人标题", "广告"]
chuanxiao = ["传销", "古币", "钱币"]
zongjiao = ["穆斯林", "基督"]
gupiao = ["推荐股票"]
vedio = ["视频打不开", "不能播放", "视频异常", "无法播放"]
kadun = ["视频无响应","视频卡"]
entry = ["找不到入口", "没有看一看", "看一看找不到", "没有入口", "找不到看一看", "没有找到入口", "看一看没有", "没有“看一看”", "没有‘看一看’", "没有\"看一看\""
, "没有\‘看一看\‘"]
faxianye = ["发现页管理", "发现管理页"]
baiping = ["看一看白屏", "白屏", "什么都不显示", "刷新后无内容", "不显示内容"]
dabukai = ["看一看打不开"]
addNewFunction = ["红点", "全选", "浏览历史", "瀏覽歷史", "一键屏蔽", "建议", "希望"]
crash = ["闪退", "重启"]
heiping = ["黑屏"]
picture = ["图片打不开", "图片加载不了"]
neirong = ["质量", "垃圾", "文理不通", "乱七八糟"]
newPoint = ["红点消不了"]
word = ["文字", "字体"]
memory = ["占内存", "占空间"]
doc = ["文章打不开"]
false = ["虚假", "骗人"]
swindle = ["诈骗"]
for j in range(int(a)):
num = 0
num2 = 0
for i in range(100):
try:
bianji = driver.find_element_by_xpath(
u"(.//*[normalize-space(text()) and normalize-space(.)=‘删除‘])[" + str(i + 1) + "]/following::button[1]")
except NoSuchElementException:
# print("这页分完")
break
con = driver.find_element_by_xpath(‘// *[ @ id = "feedTable"] / tbody / tr[‘ + str(i + 1) + ‘] / td[6]‘)
osCon = driver.find_element_by_xpath("//*[ @ id = ‘feedTable‘]/tbody/tr[" + str(i + 1) + "]/td[3]")
try:
for a in yinsi:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("担心泄露隐私")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in neirong:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("内容质量差")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in swindle:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("传销诈骗")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in false:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("虚假信息")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in turnOff:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("想关闭")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in heiping:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("黑屏")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in crash:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("闪退")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in sex:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("色情低俗")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in picture:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("图片加载不出")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in title:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("标题党")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in chuanxiao:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("传销诈骗")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in zongjiao:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("宗教反馈")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in gupiao:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("推股荐股")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in vedio:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("视频无法播放")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in kadun:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("视频卡顿")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in newPoint:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("红点消不了")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in word:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("字体反馈")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in doc:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("文章打不开")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in entry:
if a in con.text:
if osCon.text[0] == "a":
os = osCon.text.split("-")
# logging.info("android os: " + str(os))
if int(os[1]) >= 27:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("用户找不到入口")
bianji.click()
num2 = num2 + 1
else:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("入口找不到")
bianji.click()
num2 = num2 + 1
elif osCon.text[0] == "i":
if osCon.text[1] == "O":
os = osCon.text.split(" ")
try:
osVersion = os[1].split(".")[0]
# logging.info("ios os: " + str(os) + ", isVersion: " + str(osVersion))
except IndexError:
continue
if int(osVersion) >= 12:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("用户找不到入口")
bianji.click()
num2 = num2 + 1
else:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("入口找不到")
bianji.click()
num2 = num2 + 1
elif osCon.text[1] == "P":
os = osCon.text.split(" ")
try:
osVersion = os[2].split(".")[0]
except IndexError:
raise KeyError
# logging.info("ios os: " + str(os) + ", isVersion: " + str(osVersion))
if int(osVersion) >= 12:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("用户找不到入口")
bianji.click()
num2 = num2 + 1
else:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("入口找不到")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in dabukai:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("打不开")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in baiping:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("白屏")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in faxianye:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("用户找不到入口")
bianji.click()
num2 = num2 + 1
raise KeyError
for a in addNewFunction:
if a in con.text:
bianji.click()
driver.find_element_by_id("mySelect").send_keys("新增功能反馈")
bianji.click()
num2 = num2 + 1
raise KeyError
except KeyError:
continue
num = num + 1
print("第%d页" % (j + 1))
print("编辑%d条" % num2)
print("未编辑%d条" % num)
print("---------------------------------------")
driver.find_element_by_id("feedTable_next").click()
x = x + num
y = y + num2
print("总共编辑了%d条" % y)
print("剩余%d条未编辑" % x)
end = datetime.datetime.now()
print("Running time:%s Second" % (end - start))
driver.close()
以上是关于用户反馈自动分类程序的主要内容,如果未能解决你的问题,请参考以下文章