Commit c1ef7414 authored by lixiaofang's avatar lixiaofang

add

parent 9615b761
This diff is collapsed.
......@@ -4,29 +4,33 @@ import random
import traceback
from log_settings import *
import logging
from auto_request import login, click, time_convs
from auto_request import login, click, time_conv
from auto_request import host, user, db, passwd
def get_data(numtime, numtime2):
def get_data(numtime):
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 > '%s' and create_time <= '%s'" % (
numtime, numtime2))
"SELECT user_id,id FROM topic WHERE is_online=1 and create_time > '%s'" % numtime)
data = cursor.fetchall()
topic_id = list(data)
topic_id_list = []
for i in topic_id and topic_id:
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()
try:
for i in topic_id and topic_id:
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:
......@@ -34,46 +38,53 @@ def get_data(numtime, numtime2):
return []
def write_id_file(id):
try:
data = open("save_topic_id.txt", "a")
data.write(id)
data.write("/n")
except:
pass
if __name__ == "__main__":
try:
time_list = [3, 4, 5, 6, 7]
for i in time_list:
numtime, numtime2 = time_convs(i + 1, i - 1)
user_id = get_data(numtime, numtime2)
dicts = {}
numtime = time_conv(10)
user_id = get_data(numtime)
dicts = {}
if user_id:
if user_id:
for i in user_id:
for i in user_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])
if i[0] not in dicts.keys():
dicts.setdefault(i[0], [])
dicts[i[0]].append(i[1])
for key, value in dicts.items():
else:
dicts[i[0]].append(i[1])
rand_num = random.randint(0, len(value) - 1)
for key, value in dicts.items():
rand_id = value[rand_num]
rand_num = random.randint(0, len(value) - 1)
time.sleep(random.randint(1, 10))
rand_id = value[rand_num]
cook = login()
urge_num = random.randint(0, 1)
if cook is not None:
for i in range(urge_num):
click(cook, rand_id)
time.sleep(random.randint(1, 10))
write_id_file(rand_id)
cook = login()
if cook is not None:
click(cook, rand_id)
else:
pass
else:
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
import time
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, click, time_conv
def write_id_file():
try:
user_ids = []
data = open("save_topic_id.txt", "r")
data2 = open("save_topic_id_three.txt", "w")
for i in data.readlines():
data2.write(i)
data2.write("\n")
user_ids.append(i)
data.truncate()
return user_ids
except:
return []
if __name__ == "__main__":
try:
user_ids = write_id_file()
lenn = len(user_ids)
random = []
for i in range(lenn / 2):
rand_num = random.randint(0, lenn)
random.append(lenn[rand_num])
for i in random:
time.sleep(random.randint(10, 50))
cook = login()
if cook is not None:
click(cook, i)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
import time
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, click, time_conv
def write_id_file():
try:
user_ids = []
data = open("save_topic_id_three.txt", "r")
for i in data.readlines():
user_ids.append(i)
data.truncate()
return user_ids
except:
return []
if __name__ == "__main__":
try:
user_ids = write_id_file()
lenn = len(user_ids)
random = []
for i in range(lenn / 2):
rand_num = random.randint(0, lenn)
random.append(lenn[rand_num])
for i in random:
time.sleep(random.randint(10,30))
cook = login()
if cook is not None:
click(cook, i)
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