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
import pymysql
import random
import traceback
import logging
from vest.request.auto_request import logins, pictorial_reply, get_majia_reply, get_pictorial_comment
from vest.request.auto_request import host, user, db, passwd
"""
离线一次性插入{1,4}条评论
"""
def get_data():
try:
print("....")
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT creator_id,id FROM community_pictorial where is_online =True ")
data = cursor.fetchall()
topic_id = list(data)
logging.info("Database version : %s " % topic_id)
return topic_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
def principal_offline_comment1():
try:
logging.info("comment offline pictorial")
user_id = get_data()
dicts = {}
for i in user_id:
follow_num = random.randint(5, 20)
for num in range(follow_num):
majia_user_id = get_majia_reply(i[0])
cook = logins(majia_user_id)
comment = get_pictorial_comment()
if cook is not None:
logging.info("get cook:%s" % cook)
logging.info("get i[1]:%s" % i[1])
logging.info("get comment:%s" % comment)
pictorial_reply(cook, i[1], comment)
else:
logging.info("no get cookies-------------")
except:
logging.error("catch exception,main:%s" % traceback.format_exc())