Commit c1ef7414 authored by lixiaofang's avatar lixiaofang

add

parent 9615b761
This diff is collapsed.
...@@ -4,20 +4,20 @@ import random ...@@ -4,20 +4,20 @@ import random
import traceback import traceback
from log_settings import * from log_settings import *
import logging 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 from auto_request import host, user, db, passwd
def get_data(numtime, numtime2): def get_data(numtime):
try: try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306) pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor() cursor = pc.cursor()
cursor.execute( cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and create_time > '%s' and create_time <= '%s'" % ( "SELECT user_id,id FROM topic WHERE is_online=1 and create_time > '%s'" % numtime)
numtime, numtime2))
data = cursor.fetchall() data = cursor.fetchall()
topic_id = list(data) topic_id = list(data)
topic_id_list = [] topic_id_list = []
try:
for i in topic_id and topic_id: for i in topic_id and topic_id:
cursor.execute( cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0") "select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0")
...@@ -27,6 +27,10 @@ def get_data(numtime, numtime2): ...@@ -27,6 +27,10 @@ def get_data(numtime, numtime2):
topic_id_list.append(i) topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list) logging.info("Database version : %s " % topic_id_list)
pc.close() pc.close()
except:
pass
return topic_id_list return topic_id_list
except: except:
...@@ -34,25 +38,31 @@ def get_data(numtime, numtime2): ...@@ -34,25 +38,31 @@ def get_data(numtime, numtime2):
return [] 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__": if __name__ == "__main__":
try: try:
time_list = [3, 4, 5, 6, 7] numtime = time_conv(10)
user_id = get_data(numtime)
for i in time_list:
numtime, numtime2 = time_convs(i + 1, i - 1)
user_id = get_data(numtime, numtime2)
dicts = {} dicts = {}
if user_id: if user_id:
for i in user_id: for i in user_id:
if i[0] not in dicts.keys(): if i[0] not in dicts.keys():
dicts.setdefault(i[0], []) dicts.setdefault(i[0], [])
dicts[i[0]].append(i[1]) dicts[i[0]].append(i[1])
else: else:
dicts[i[0]].append(i[1]) dicts[i[0]].append(i[1])
...@@ -62,16 +72,17 @@ if __name__ == "__main__": ...@@ -62,16 +72,17 @@ if __name__ == "__main__":
rand_id = value[rand_num] rand_id = value[rand_num]
urge_num = random.randint(0, 1)
for i in range(urge_num):
time.sleep(random.randint(1, 10)) time.sleep(random.randint(1, 10))
cook = login() cook = login()
if cook is not None: if cook is not None:
click(cook, rand_id) click(cook, rand_id)
write_id_file(rand_id)
else: else:
pass pass
......
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