Commit 32f9ecdd authored by lixiaofang's avatar lixiaofang

add

parent 6f49cab6
This diff is collapsed.
...@@ -6,30 +6,33 @@ import random ...@@ -6,30 +6,33 @@ import random
import traceback import traceback
from log_settings import * from log_settings import *
import logging import logging
from auto_request import login, time_convs, follow from auto_request import login, time_convs, follow, Urge
from auto_request import host, user, db, passwd from auto_request import host, user, db, passwd
def get_data(numtime): 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="physical", port=3306)
cursor = pc.cursor() cursor = pc.cursor()
cursor.execute( cursor.execute(
"select distinct(user_id) from pv_maidian where page_name ='home' and partiton_date > '%s'" % numtime) "select user_id from sl_user_login_status where last_visit_day < '%s' and is_shadow =0 " % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
topic_id_list = [] logging.info("Database version : %s " % user_id)
for i in user_id and user_id: # topic_id_list = []
cursor.execute( # for i in user_id and user_id:
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0 ") # pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
data = cursor.fetchall() # cursor = pc.cursor()
user_id = list(data) # cursor.execute(
if user_id: # "select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0 ")
topic_id_list.append(i) # data = cursor.fetchall()
# user_id = list(data)
# if user_id:
# 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()
return topic_id_list return user_id
except: except:
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return None
...@@ -37,20 +40,12 @@ def get_data(numtime): ...@@ -37,20 +40,12 @@ def get_data(numtime):
if __name__ == "__main__": if __name__ == "__main__":
try: try:
numtime1, numtime2 = time_convs(1, 2) numtime1, numtime2 = time_convs(1, 3)
user_id = get_data(numtime2)
user_id = get_data(numtime1) for i in user_id:
urge_num = random.randint(0, 1) id = int(i[0])
for j in range(urge_num): cook = login()
try: if cook is not None:
for i in user_id and user_id: Urge(cook, id)
id = int(i[0])
time.sleep(random.randint(10, 30))
cook = login()
if cook is not None:
follow(cook, id)
except:
pass
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
import requests
import time
import datetime
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, time_convs, follow, Urge
from auto_request import host, user, db, passwd
def get_data(numtime):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db="physical", port=3306)
cursor = pc.cursor()
cursor.execute(
"select user_id from sl_user_login_status where last_visit_day < '%s' and is_shadow = 0 " % numtime)
data = cursor.fetchall()
user_id = list(data)
# topic_id_list = []
# for i in user_id and user_id:
# pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
# cursor = pc.cursor()
# 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 " % user_id)
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
try:
numtime1, numtime2 = time_convs(1, 3)
user_id = get_data(numtime2)
num = random.randint(0, 1)
if num == 1:
for i in user_id and user_id:
id = int(i[0])
cook = login()
if cook is not None:
Urge(cook, id)
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