1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import time
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, click, time_conv
from auto_request import host, user, db, passwd
def get_data(numtime, numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >= '2019-05-01 00:00:00.000000' and create_time <= '2019-05-13 00:00:00.000000')")
data = cursor.fetchall()
topic_id = list(data)
topic_id_list = []
try:
for i in topic_id:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute("select topic_id from reply where topic_id =" + str(i[1]))
data_s = cursor.fetchall()
topic_id_s = list(data_s)
if len(topic_id_s) == 0:
try:
cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0")
data = cursor.fetchall()
user_id = list(data)
if user_id:
topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list)
pc.close()
except:
pass
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
if __name__ == "__main__":
try:
numtime, numtime2 = time_conv(15, 5)
user_id = get_data(numtime, numtime2)
dicts = {}
for i in user_id:
cook = login()
if cook is not None:
click(cook, i[1])
except:
logging.error("catch exception,main:%s" % traceback.format_exc())