Commit 69b5b059 authored by lixiaofang's avatar lixiaofang

add

parent 69f8e88c
# -*- coding: UTF-8 -*-
import requests
import time
import datetime
import pymysql
import random
import pandas as pd
import threading
import traceback
from log_settings import *
import logging
from celery import shared_task
from django.conf import settings
from get_session import get_comments, get_cookies, click, time_conv, login, reply
from majia import get_comments, get_cookies, click, time_conv, login, reply
from majia import host, user, passwd, db
exec_count = 0
@shared_task
def auto_click(es_type, id):
def auto_click(pk_list):
exec_count = 0
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(
id) + " and user_id in (select user_id from user_extra where is_shadow = 0)")
"SELECT id,user_id FROM topic WHERE id in " + str(
tuple(pk_list)) + " 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 = 919337
exec_count = 0
if topic_id_list:
......@@ -39,23 +40,19 @@ def auto_click(es_type, id):
exec_count += 1
if exec_count == 1:
logging.info("-----1-------")
# sleep_time = random.randint(300, 540)
sleep_time = 30
timer = threading.Timer(sleep_time, fun_timer)
timer.start()
if exec_count == 2:
logging.info("-----2-------")
# 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()
......@@ -67,19 +64,18 @@ def auto_click(es_type, id):
@shared_task
def auto_reply(es_type,id):
def auto_reply(pk_list):
exec_count = 0
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(
id) + " and user_id in (select user_id from user_extra where is_shadow = 0)")
"SELECT id,user_id FROM topic WHERE id in " + str(
tuple(pk_list)) + " 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 = 919337
exec_count = 0
if topic_id_list:
......@@ -88,19 +84,21 @@ def auto_reply(es_type,id):
if cookies:
comment_content = get_comments()
comment = comment_content[0]
reply(cookies, id, comment)
reply(cookies, topic_id_list[0], comment)
global timer
global exec_count
exec_count += 1
if exec_count == 1:
logging.info("-----13-------")
sleep_time = random.randint(300, 540)
sleep_time = 30
timer = threading.Timer(sleep_time, fun_comment)
timer.start()
if exec_count == 2:
logging.info("-----14-------")
sleep_time = random.randint(1000, 1900)
sleep_time = 30
timer = threading.Timer(sleep_time, fun_comment)
......@@ -113,4 +111,3 @@ def auto_reply(es_type,id):
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
This diff is collapsed.
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