Commit 64c527f1 authored by lixiaofang's avatar lixiaofang

add

parent 8223481f
This diff is collapsed.
......@@ -6,31 +6,22 @@ import random
import traceback
from log_settings import *
import logging
from auto_request import login, time_conv, follow, get_cookies
from auto_request import login, time_conv, follow, get_cookies, time_now
from auto_request import host, user, db, passwd
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 account_user_auth where user_id not in (select user_id from pv_maidian where page_name ='home' and partiton_date >= %s )",
(numtime))
"select distinct(user_id) from topic where is_online=1 and create_time > '%s' and create_time < '%s' and is_shadow = 0" % (
numtime1, numtime2))
data = cursor.fetchall()
user_id = list(data)
topic_id_list = []
for i in user_id and user_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)
logging.info("Database version : %s " % user_id)
pc.close()
return topic_id_list
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
......@@ -38,27 +29,17 @@ def get_data(numtime):
if __name__ == "__main__":
try:
numtime = time_conv(3, 2)
user_id = get_data(numtime)
urge_num = random.randint(1, 2)
numtime1, numtime2 = time_now(10)
for j in range(urge_num):
user_id = get_data(numtime1, numtime2)
try:
for i in user_id and user_id:
cookies = get_cookies(i)
for i in user_id and user_id:
time.sleep(random.randint(10, 40))
cookies = get_cookies(i)
cook = login()
cook = login()
if cook is not None:
follow(cook, i)
except:
pass
if cook is not None:
follow(cook, i)
except:
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_conv, follow, get_cookies, time_now
from auto_request import host, user, db, passwd
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' and create_time < '%s' and is_shadow = 0" % (
numtime1, numtime2))
data = cursor.fetchall()
user_id = list(data)
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_now(10)
user_id = get_data(numtime1, numtime2)
for i in user_id and user_id:
num = random.randint(0, 1)
if num == 1:
cookies = get_cookies(i)
cook = login()
if cook is not None:
follow(cook, i)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -41,9 +41,9 @@ 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:
for i in user_id and user_id:
num = random.randint(0, 1)
if num == 1:
id = int(i[0])
cook = login()
if cook is not None:
......
......@@ -162,6 +162,15 @@ def time_conv(minutest, minutest2):
return None
def time_now(minutest):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(hours=minutest)
return yes_time,now
except:
return None
def time_convs(numtime, numtime2):
try:
now = datetime.datetime.now()
......
......@@ -44,14 +44,9 @@ if __name__ == "__main__":
numtime1, numtime2 = time_convs(3, 2)
user_id = get_data(numtime1)
for j in range(1):
try:
for i in user_id and user_id:
time.sleep(random.randint(10, 15))
cook = login()
if cook is not None:
Urge(cook, i)
except:
pass
for i in user_id and user_id:
cook = login()
if cook is not None:
Urge(cook, i)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -43,15 +43,12 @@ if __name__ == "__main__":
try:
numtime1, numtime2 = time_convs(3, 2)
user_id = get_data(numtime1)
urge_num = random.randint(0, 1)
if urge_num == 1:
try:
for i in user_id and user_id:
time.sleep(random.randint(10, 15))
cook = login()
if cook is not None:
Urge(cook, i)
except:
pass
for i in user_id and user_id:
urge_num = random.randint(0, 1)
if urge_num == 1:
cook = login()
if cook is not None:
Urge(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