Commit 1625fbf1 authored by lixiaofang's avatar lixiaofang

add

parent ba05f067
This diff is collapsed.
......@@ -56,7 +56,7 @@ if __name__ == "__main__":
numtime1, numtime2 = time_convs(1, 1)
user_id = get_topic_new_user(numtime1,numtime2)
user_id = get_topic_new_user(numtime1, numtime2)
follow_num = random.randint(1, 2)
......
......@@ -54,9 +54,9 @@ if __name__ == "__main__":
for i in range(follow_num):
if user_id:
try:
for j in user_id:
for j in user_id and user_id:
id = int(j[0])
......@@ -67,8 +67,8 @@ if __name__ == "__main__":
if cookies is not None:
follow(cookies, id)
time.sleep(60)
except:
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -105,20 +105,24 @@ if __name__ == "__main__":
user_id = get_commnet_id(numtime1)
for j in user_id and user_id:
try:
id = int(j[0])
for j in user_id and user_id:
follow_num = random.randint(0, 1)
id = int(j[0])
for i in range(follow_num):
follow_num = random.randint(0, 1)
time.sleep(random.randint(10, 50))
for i in range(follow_num):
cookies = login()
time.sleep(random.randint(10, 50))
if cookies is not None:
follow(cookies, id)
cookies = login()
if cookies is not None:
follow(cookies, id)
except:
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -46,16 +46,19 @@ if __name__ == "__main__":
for j in range(urge_num):
for i in user_id and user_id:
try:
cookies = get_cookies(i)
for i in user_id and user_id:
time.sleep(random.randint(10, 40))
cookies = get_cookies(i)
cook = login()
time.sleep(random.randint(10, 40))
if cook is not None:
follow(cook, i)
cook = login()
if cook is not None:
follow(cook, i)
except:
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -10,12 +10,13 @@ from auto_request import login, time_convs, follow, click
from auto_request import host, user, db, passwd
def get_star_user_id(numtime):
def get_star_user_id(numtime1, numtime2):
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 (content_level =4 or content_level =5) and create_time > '%s' " % numtime)
"SELECT user_id,id FROM topic WHERE is_online=1 and (content_level =4 or content_level =5) and create_time > '%s' and create_time < '%s' " % (
numtime1, numtime2))
data = cursor.fetchall()
user_id_list = list(data)
logging.info("Database version : %s " % user_id_list)
......@@ -45,11 +46,11 @@ if __name__ == "__main__":
numtime1, numtime2 = time_convs(i + 1, i - 1)
user_topic_id = get_star_user_id(numtime1)
user_topic_id = get_star_user_id(numtime1,numtime2)
if user_topic_id:
try:
for j in user_topic_id:
for j in user_topic_id and user_topic_id:
id = int(j[1])
......@@ -63,6 +64,8 @@ if __name__ == "__main__":
if cookies is not None:
click(cookies, id)
except:
pass
user_id = get_star_user_id(numtime1)
......
......@@ -10,12 +10,13 @@ from auto_request import login, time_convs, Urge
from auto_request import host, user, db, passwd
def get_star_useid(numtime):
def get_star_useid(numtime1, numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT distinct(user_id) FROM topic WHERE is_online=1 and (content_level =4 or content_level =5) and create_time > '%s'" % numtime)
"SELECT distinct(user_id) FROM topic WHERE is_online=1 and (content_level =4 or content_level =5) and create_time > '%s' and create_time < '%s'" % (
numtime1, numtime2))
data = cursor.fetchall()
user_id = list(data)
topic_id_list = []
......@@ -42,22 +43,27 @@ if __name__ == "__main__":
for i in time_list:
numtime1, numtime2 = time_convs(i + 1,i-1)
numtime1, numtime2 = time_convs(i + 1, i - 1)
user_id = get_star_useid(numtime1)
user_id = get_star_useid(numtime1,numtime2)
for j in user_id and user_id:
try:
id = int(j[0])
for j in user_id and user_id:
for i in range(1):
id = int(j[0])
time.sleep(random.randint(10, 50))
for i in range(1):
cookies = login()
time.sleep(random.randint(10, 50))
if cookies is not None:
Urge(cookies, id)
cookies = login()
if cookies is not None:
Urge(cookies, id)
except:
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -11,12 +11,12 @@ from auto_request import host, user, db, passwd
import threading
def get_data(numtime):
def get_data(numtime1,numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time > '%s'" % numtime)
"SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time > '%s' and create_time < '%s'" % (numtime1,numtime2))
data = cursor.fetchall()
user_id = list(data)
......@@ -48,21 +48,24 @@ if __name__ == "__main__":
numtime1, numtime2 = time_convs(i + 1, i - 1)
user_id = get_data(numtime1)
user_id = get_data(numtime1,numtime2)
urge_num = random.randint(0, 2)
for i in range(urge_num):
try:
for j in user_id and user_id:
for j in user_id and user_id:
id = int(j[0])
id = int(j[0])
time.sleep(random.randint(10, 50))
time.sleep(random.randint(10, 50))
cookies = login()
cookies = login()
if cookies is not None:
Urge(cookies, id)
if cookies is not None:
Urge(cookies, id)
except:
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -50,20 +50,18 @@ if __name__ == "__main__":
for j in range(2):
for i in user_id and user_id:
try:
time.sleep(random.randint(10, 15))
for i in user_id and user_id:
cook = login()
time.sleep(random.randint(10, 15))
if cook is not None:
Urge(cook, i)
sleep_time = random.randint(300, 540)
timer = threading.Timer(1, urge_user) # 首次启动
timer.start()
cook = login()
if cook is not None:
Urge(cook, i)
except:
pass
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