博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
用户反馈自动分类程序
阅读量:5044 次
发布时间:2019-06-12

本文共 9416 字,大约阅读时间需要 31 分钟。

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()

'''

 

#优化部分重复代码

dict = {      "yinsi" : ["隐私", "私隐", "不想别人看", "隱私", "稳私", "泄露", "瘾私" ],   "turnoff" : ["关闭", "关掉", "不想要这个功能"],
  "neirong": ["质量", "垃圾", "文理不通", "乱七八糟"],
} content={
"yinsi":"担心泄露隐私", "turnoff":"想关闭", "neirong":"内容质量差", "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: 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]") print(con.text) try: for k ,v in dict.items(): for a in v: if a in con.text: print(content[k]) '''bianji.click() driver.find_element_by_id("mySelect").send_keys(content.key(k)) 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()

转载于:https://www.cnblogs.com/bingna/p/11546461.html

你可能感兴趣的文章
静态页面复习--用semantic UI写一个10min首页
查看>>
在Windows下安装64位压缩包版mysql 5.7.11版本的方法
查看>>
drf权限组件
查看>>
输入月份和日期,得出是今年第几天
查看>>
利用mysqldump备份mysql
查看>>
Qt中子窗口全屏显示与退出全屏
查看>>
使用brew安装软件
查看>>
[BZOJ1083] [SCOI2005] 繁忙的都市 (kruskal)
查看>>
吴裕雄 python 机器学习——数据预处理嵌入式特征选择
查看>>
Centos6.4安装JDK
查看>>
201521123069 《Java程序设计》 第4周学习总结
查看>>
线性表的顺序存储——线性表的本质和操作
查看>>
【linux】重置fedora root密码
查看>>
用swing做一个简单的正则验证工具
查看>>
百度坐标(BD-09)、国测局坐标(火星坐标,GCJ-02)和WGS-84坐标互转
查看>>
pig自定义UDF
查看>>
输入名字显示其生日,没有则让输入生日,做记录
查看>>
爬虫综合大作业
查看>>
Kubernetes 运维学习笔记
查看>>
并查集 经典 畅通工程
查看>>