User feedback automatic classification program

1. Install and Python PyCharm,

 code show as below

#!/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

 

datetime.datetime.now = Start ()
Driver = webdriver.Chrome ()
driver.maximize_window () # maximize browser

driver.implicitly_wait (5) # wait time set implicit

driver.get ( "http: // XXXXXX") # Modify Home address needs execution of the program

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

Array # key word
yinsi = [ "Privacy", "Privacy", "do not want others to see," "privacy," "steady private", "leaked", "addiction private"]
turnoffShowing = [ "close", " off, "" do not want this function "]
Sex = [" pornography "," vulgar "]
title = [" title of the party, "" irrelevant, "" mistaken identity "," does not match the title and content "," shocking title " "Advertising"]
chuanxiao = [ "pyramid schemes", "ancient coins", "money"]
zongjiao = [ "Muslim", "Christ"]
gupiao = [ "recommended stocks"]
Vedio = [ "open video" "can not play", "video abnormality", "can not play"]
kadun = [ "video is not responding," "video card"]
entry = [ "can not find entry", "no look", "look not found "," no entry "," can not find a look, "" no entry found ","See no "," do not "see" "," no "see" "," No \ "look \" "
," no \ "look \" ']
faxianye = [ " found page management "," discovery management page "]
Baiping = [" look black and white "," black and white "," nothing is displayed, "" refresh content "," without content "]
dabukai = [ "Take a look open"]
addNewFunction = [ "red dot", "Select", "browsing history", "browsing history", "a key mask", "rECOMMENDED", "hope"]
Crash = [ " flash back "," restart "]] Dabukai = [ "open look"] addNewFunction = [ "red dot", "Select", "browsing history", "browsing history", "a key mask", "RECOMMENDED", "hope"] crash = [ "flash back", "restart"]] Dabukai = [ "open look"] addNewFunction = [ "red dot", "Select", "browsing history", "browsing history", "a key mask", "RECOMMENDED", "hope"] crash = [ "flash back", "restart"]
heiping = [ "black"]
Picture = [ "picture open", "can not load the image"]
neirong = [ "quality", "waste", "Arts and not", "mess"]
Newpoint = [ "red dot elimination not "]
Word = [" text "," Font "]
memory = [" total memory "," take up space "]
DOC = [" article open "]
false = [" false "," lie "]
Swindle = [ "fraud"]

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 (the osVersion)> = 12 is:
bianji.click ()
driver.find_element_by_id ( "MySELECT") send_keys ( "User entry not found").
bianji.click ()
num2 = num2 +. 1
the else:
bianji.click ( )
. driver.find_element_by_id ( "MySELECT") send_keys ( "entry not found")
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

A in faxianye for:
IF A in con.text:
bianji.click ()
. driver.find_element_by_id ( "MySELECT") send_keys ( "User entry not found")
bianji.click ()
num2 = num2 +. 1
The raise a 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 ( "page% d"% (. 1 + J))
print ( "% d edit article" num2%)
print ( "% d unedited article" NUM%)
print ( "--------- ------------------------------ ")
driver.find_element_by_id (" feedTable_next "). the Click ()
X NUM = X +
Y num2 + Y =
Print ( "edited total of% d"% Y)
Print ( "% d article remaining unedited" X%)
End = datetime.datetime.now ()
Print ( "Running Time: S% Second"% (End - Start))
driver.close ()

Guess you like

Origin www.cnblogs.com/bingna/p/11546461.html