Commit cf9377da authored by lixiaofang's avatar lixiaofang

add

parent 752d1826
This diff is collapsed.
import requests
import time
import datetime
import pymysql
import random
import pandas as pd
import traceback
from log_settings import *
import logging
from auto_request import login, reply, click, get_comments, time_conv,get_user_id
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 >= %s",(numtime))
data = cursor.fetchall()
topic_id = list(data)
user_list = get_user_id()
topic_id_list = []
if topic_id:
for i in topic_id:
if int(i[1]) not in user_list:
topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list)
pc.close()
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
try:
numtime = time_conv(15)
topic_id = get_topic_id(numtime)
click_num = random.randint(1, 5)
for i in range(click_num):
for j in topic_id:
id = int(j[0])
cookies = login()
time.sleep(random.randint(10, 20))
click(cookies, id)
time.sleep(300)
topic_id = get_topic_id(numtime)
comment_num = random.randint(0, 3)
comment_content = get_comments()
for i in range(comment_num):
for j in topic_id:
id = int(j[0])
cookies = login()
if cookies is not None:
comment = comment_content[i]
time.sleep(random.randint(10, 20))
reply(cookies, id, comment)
time.sleep(300)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
# 发帖瞬时:[1 - 5]个马甲点赞
# 1. 用户发帖后,[瞬时],1-3条评论
......@@ -79,5 +79,3 @@ if __name__ == "__main__":
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
# 7天后,每日一次轮询,3*n日前新增帖子:[0-1]个马甲点赞。每天每人最多一个帖子点赞。
......@@ -48,10 +48,7 @@ if __name__ == "__main__":
numtime = time_convs(i)
# topic_id = get_topic_id(numtime)
topic_id = [(241581376, 5479267), (241439646, 5479268), (241439646, 5479269), (241407671, 5479270),
(241407671, 5479271), (241581395, 5479272)]
topic_id = get_topic_id(numtime)
dicts = {}
......
......@@ -3,7 +3,6 @@ import time
import datetime
import pymysql
import random
import pandas as pd
import traceback
from log_settings import *
import logging
......
......@@ -3,7 +3,6 @@ import time
import datetime
import pymysql
import random
import pandas as pd
import traceback
from log_settings import *
import logging
......
import requests
import time
import datetime
import pymysql
import random
import traceback
import logging
from log_settings import *
from auto_request import login, time_convs, reply, get_comment
from auto_request import host, user, db, passwd
cookies = login()
reply(cookies, id=1, content='来啦来啦来啦来啦来啦')
import requests
import time
import datetime
import pymysql
import random
import pandas as pd
import traceback
from log_settings import *
import logging
from auto_request import login, click, get_comments, reply
import threading
from auto_request import host, user, db, passwd
if __name__ == "__main__":
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT id,user_id FROM topic WHERE id = " + str(
45456) + " and user_id in (select user_id from user_extra where is_shadow = 0)")
data = cursor.fetchall()
topic_id_list = list(data)
logging.info("Database version : %s " % topic_id_list)
pc.close()
topic_id_list = [87]
exec_count = 0
if topic_id_list:
def fun_comment():
cookies = login()
if cookies:
comment_content = get_comments()
logging.info("get comment:%s" % comment_content)
num = random.randint(0, 2)
comment = comment_content[num]
logging.info("get comment:%s" % comment)
reply(cookies, topic_id_list[0], comment)
global timer
global exec_count
exec_count += 1
if exec_count == 1:
print("----1------")
sleep_time = random.randint(300, 540)
sleep_time = 30
timer = threading.Timer(sleep_time, fun_comment)
timer.start()
if exec_count == 2:
print("----2------")
sleep_time = random.randint(1000, 1900)
sleep_time = 30
timer = threading.Timer(sleep_time, fun_comment)
timer.start()
# def fun_timer():
# cookies = login()
# if cookies:
# click(cookies, topic_id_list[0])
#
# global timer
# global exec_count
#
# exec_count += 1
# if exec_count == 1:
# print("----3------")
#
# # sleep_time = random.randint(300, 540)
# sleep_time = 30
# timer = threading.Timer(sleep_time, fun_timer)
# timer.start()
#
# if exec_count == 2:
# print("----4------")
#
# # sleep_time = random.randint(1000, 1900)
# sleep_time = 50
# timer = threading.Timer(sleep_time, fun_timer)
# timer.start()
sleep_time = random.randint(300, 540)
timer = threading.Timer(10, fun_comment) # 首次启动
timer.start()
# sleep_time = random.randint(300, 540)
# timer = threading.Timer(10, fun_timer) # 首次启动
# timer.start()
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment