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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import requests
import time
import datetime
import pymysql
import random
import traceback
import logging
from auto_request import login, time_convs, reply, get_comment
from auto_request import host, user, port, db, passwd
def get_topic_id(numtime):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0) " % numtime)
data = cursor.fetchall()
topic_id = list(data)
logging.info("Database version : %s " % topic_id)
pc.close()
return topic_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
try:
time_list = [1, 2, 3, 4, 5, 6, 7]
for i in time_list:
numtime = time_convs(i)
topic_id = get_topic_id(numtime)
dicts = {}
for i in topic_id:
if i[0] not in dicts.keys():
dicts.setdefault(i[0], [])
dicts[i[0]].append(i[1])
else:
dicts[i[0]].append(i[1])
comment = get_comment()
for key, value in dicts.items():
rand_num = random.randint(0, len(value) - 1)
rand_id = value[rand_num]
for i in range(1):
time.sleep(random.randint(10, 20))
cook = login()
if cook is not None:
reply(cook, id, comment)
except:
logging.error("catch exception,main :%s" % traceback.format_exc())
#. 每日一次轮询,昨、2、3、4、5、6、7日新增帖的用户:随机从马甲库里取一个马甲,搭配随机评论库一条评论。每天每人最多一个帖子被评论。