Commit 77f4e958 authored by lixiaofang's avatar lixiaofang

add

parent a78a48b1
This diff is collapsed.
...@@ -7,149 +7,152 @@ import pandas as pd ...@@ -7,149 +7,152 @@ import pandas as pd
import traceback import traceback
from log_settings import * from log_settings import *
import logging import logging
from auto_request import login, reply, click, get_comment, time_conv
auto_click_url = "http://earth.iyanzhi.com/api/v1/like" from auto_request import host, user, port, db, passwd
auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
# auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
# auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
def get_majia(): # auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list = [] # def get_majia():
for i in data: # try:
list.append(i.strip('\n').strip(',')) # data = open("/srv/apps/cybertron/batch_user_gen")
maj = random.randint(1, len(list)) # list = []
user_id = list[maj - 1] # for i in data:
return user_id # list.append(i.strip('\n').strip(','))
# maj = random.randint(1, len(list))
except: # user_id = list[maj - 1]
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) # return user_id
return None #
# except:
# logging.error("catch exception,get_majia:%s" % traceback.format_exc())
def get_cookies(user_id): # return None
try: #
with open("/srv/apps/cybertron/user_session.txt", 'r') as f: #
try: # def get_cookies(user_id):
data = f.readlines() # try:
except: # with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
data = None # try:
# data = f.readlines()
list = [] # except:
for i in data: # data = None
list.append(i.strip('\n').split(",")) #
# list = []
for i in list: # for i in data:
# list.append(i.strip('\n').split(","))
if user_id == i[0]: #
return (i[1]) # for i in list:
except: #
# if user_id == i[0]:
return None # return (i[1])
# except:
#
def login(): # return None
try: #
user_id = get_majia() #
# def login():
cookies = get_cookies(user_id) # try:
# user_id = get_majia()
if cookies is not None: #
return {'sessionid': cookies} # cookies = get_cookies(user_id)
#
except: # if cookies is not None:
# return {'sessionid': cookies}
logging.error("catch exception,logins:%s" % traceback.format_exc()) #
# except:
return None #
# logging.error("catch exception,logins:%s" % traceback.format_exc())
#
def click(cookies_get, id): # return None
try: #
post_dict = { #
'type': 0, # def click(cookies_get, id):
'id': id # try:
} # post_dict = {
response = requests.post(url=auto_click_url, # 'type': 0,
cookies=cookies_get, # 'id': id
data=post_dict) # }
# response = requests.post(url=auto_click_url,
logging.info("response.text:%s" % response.text) # cookies=cookies_get,
# data=post_dict)
except: #
# logging.info("response.text:%s" % response.text)
logging.error("catch exception,logins:%s" % traceback.format_exc()) #
# except:
#
def reply(cookies_get, id, content): # logging.error("catch exception,logins:%s" % traceback.format_exc())
try: #
post_dict = { #
'topic_id': id, # def reply(cookies_get, id, content):
'content': content # try:
} # post_dict = {
response = requests.post(url=auto_reply_url, # 'topic_id': id,
cookies=cookies_get, # 'content': content
data=post_dict) # }
# response = requests.post(url=auto_reply_url,
logging.info("response.text:%s" % response.text) # cookies=cookies_get,
# data=post_dict)
except: #
# logging.info("response.text:%s" % response.text)
logging.error("catch exception,logins:%s" % traceback.format_exc()) #
# except:
#
def time_conv(): # logging.error("catch exception,logins:%s" % traceback.format_exc())
try: #
now = datetime.datetime.now() #
yes_time = now - datetime.timedelta(minutes=15) # def time_conv():
print(yes_time) # try:
return yes_time # now = datetime.datetime.now()
# yes_time = now - datetime.timedelta(minutes=15)
except: # print(yes_time)
return None # return yes_time
#
# except:
# return None
#
#
# def get_comment():
# try:
# data = open("/srv/apps/cybertron/guanshui", "r")
# list_guanshui = []
# for i in data:
# list_guanshui.append(i)
# num = random.randint(0, len(list_guanshui))
# comment = list_guanshui[num - 1]
#
# return comment
#
# except:
#
# return None
def get_topic_id(numtime): def get_topic_id(numtime):
try: try:
db = pymysql.connect(host="172.17.40.144", user='work', passwd='oars152!traipseize738', pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
db="alpha", port=3306) cursor = pc.cursor()
cursor = db.cursor()
cursor.execute( cursor.execute(
"SELECT id,user_id FROM topic WHERE is_online =1 and create_time >= %s and user_id in (select user_id from user_extra where is_shadow = 0)", "SELECT id,user_id FROM topic WHERE is_online =1 and create_time >= %s and user_id in (select user_id from user_extra where is_shadow = 0)",
(numtime)) (numtime))
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() pc.close()
return user_id 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
def get_comment():
try:
data = open("/srv/apps/cybertron/guanshui", "r")
list_guanshui = []
for i in data:
list_guanshui.append(i)
num = random.randint(0, len(list_guanshui))
comment = list_guanshui[num - 1]
return comment
except:
return None
if __name__ == "__main__": if __name__ == "__main__":
try: try:
numtime = time_conv() numtime = time_conv(15)
topic_id = get_topic_id(numtime) topic_id = get_topic_id(numtime)
click_num = random.randint(1, 3) click_num = random.randint(1, 3)
for i in range(click_num): for i in range(click_num):
......
...@@ -6,106 +6,103 @@ import random ...@@ -6,106 +6,103 @@ 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
auto_click_url = "http://earth.iyanzhi.com/api/v1/like" from auto_request import host,user,port,db,passwd
def get_majia(): # def get_majia():
try: # try:
data = open("/srv/apps/cybertron/batch_user_gen") # data = open("/srv/apps/cybertron/batch_user_gen")
#
list = [] # list = []
#
for i in data: # for i in data:
list.append(i.strip('\n').strip(',')) # list.append(i.strip('\n').strip(','))
#
maj = random.randint(1, len(list)) # maj = random.randint(1, len(list))
#
user_id = list[maj - 1] # user_id = list[maj - 1]
#
return user_id # return user_id
#
except: # except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) # logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None # return None
#
#
def get_cookies(user_id): # def get_cookies(user_id):
try: # try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f: # with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try: # try:
data = f.readlines() # data = f.readlines()
except: # except:
data = None # data = None
#
list = [] # list = []
for i in data: # for i in data:
list.append(i.strip('\n').split(",")) # list.append(i.strip('\n').split(","))
#
for i in list: # for i in list:
#
if user_id == i[0]: # if user_id == i[0]:
return (i[1]) # return (i[1])
except: # except:
#
return None # return None
#
#
def login(): # def login():
try: # try:
user_id = get_majia() # user_id = get_majia()
#
cookies = get_cookies(user_id) # cookies = get_cookies(user_id)
#
if cookies is not None: # if cookies is not None:
return {'sessionid': cookies} # return {'sessionid': cookies}
#
except: # except:
#
logging.error("catch exception,logins:%s" % traceback.format_exc()) # logging.error("catch exception,logins:%s" % traceback.format_exc())
#
return None # return None
#
#
def click(cookies_get, id): # def click(cookies_get, id):
try: # try:
post_dict = { # post_dict = {
'type': 0, # 'type': 0,
'id': id # 'id': id
} # }
response = requests.post(url=auto_click_url, # response = requests.post(url=auto_click_url,
cookies=cookies_get, # cookies=cookies_get,
data=post_dict) # data=post_dict)
#
logging.info("response.text:%s" % response.text) # logging.info("response.text:%s" % response.text)
#
except: # except:
#
logging.error("catch exception,logins:%s" % traceback.format_exc()) # logging.error("catch exception,logins:%s" % traceback.format_exc())
#
#
def time_conv(numtime): # def time_conv(numtime):
try: # try:
now = datetime.datetime.now() # now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime) # yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d') # yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str # return yes_time_str
except: # except:
return None # return None
def get_data(numtime): def get_data(numtime):
try: try:
db = pymysql.connect(host="172.17.40.144", user='work', pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
passwd='oars152!traipseize738', cursor = pc.cursor()
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute( cursor.execute(
"SELECT distinct(user_id),id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime) "SELECT distinct(user_id),id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() pc.close()
return user_id 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())
...@@ -120,7 +117,7 @@ if __name__ == "__main__": ...@@ -120,7 +117,7 @@ if __name__ == "__main__":
for i in time_list: for i in time_list:
numtime = time_conv(i) numtime = time_convs(i)
user_id = get_data(numtime) user_id = get_data(numtime)
......
...@@ -5,107 +5,106 @@ import pymysql ...@@ -5,107 +5,106 @@ import pymysql
import random import random
import traceback import traceback
import logging import logging
from auto_request import login, click, time_convs
auto_click_url = "http://earth.iyanzhi.com/api/v1/like" from auto_request import host,user,port,db,passwd
def get_majia():
try: # def get_majia():
data = open("/srv/apps/cybertron/batch_user_gen") # try:
# data = open("/srv/apps/cybertron/batch_user_gen")
list = [] #
# list = []
for i in data: #
list.append(i.strip('\n').strip(',')) # for i in data:
# list.append(i.strip('\n').strip(','))
maj = random.randint(1, len(list)) #
# maj = random.randint(1, len(list))
user_id = list[maj - 1] #
# user_id = list[maj - 1]
return user_id #
# return user_id
except: #
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) # except:
return None # logging.error("catch exception,get_majia:%s" % traceback.format_exc())
# return None
#
def get_cookies(user_id): #
try: # def get_cookies(user_id):
with open("/srv/apps/cybertron/user_session.txt", 'r') as f: # try:
try: # with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
data = f.readlines() # try:
except: # data = f.readlines()
data = None # except:
# data = None
list = [] #
for i in data: # list = []
list.append(i.strip('\n').split(",")) # for i in data:
# list.append(i.strip('\n').split(","))
for i in list: #
# for i in list:
if user_id == i[0]: #
return (i[1]) # if user_id == i[0]:
except: # return (i[1])
# except:
return None #
# return None
#
def logins(): #
try: # def logins():
user_id = get_majia() # try:
# user_id = get_majia()
cookies = get_cookies(user_id) #
# cookies = get_cookies(user_id)
if cookies is not None: #
return {'sessionid': cookies} # if cookies is not None:
# return {'sessionid': cookies}
except: #
# except:
logging.error("catch exception,logins:%s" % traceback.format_exc()) #
# logging.error("catch exception,logins:%s" % traceback.format_exc())
return None #
# return None
#
def click(cookies_get, id): #
try: # def click(cookies_get, id):
post_dict = { # try:
'type': 0, # post_dict = {
'id': id # 'type': 0,
} # 'id': id
response = requests.post(url=auto_click_url, # }
cookies=cookies_get, # response = requests.post(url=auto_click_url,
data=post_dict) # cookies=cookies_get,
# data=post_dict)
logging.info("response.text:%s" % response.text) #
# logging.info("response.text:%s" % response.text)
except: #
# except:
logging.error("catch exception,logins:%s" % traceback.format_exc()) #
# logging.error("catch exception,logins:%s" % traceback.format_exc())
#
def time_conv(numtime): #
try: # def time_conv(numtime):
now = datetime.datetime.now() # try:
yes_time = now - datetime.timedelta(days=numtime) # now = datetime.datetime.now()
yes_time_str = yes_time.strftime('%Y-%m-%d') # yes_time = now - datetime.timedelta(days=numtime)
return yes_time_str # yes_time_str = yes_time.strftime('%Y-%m-%d')
except: # return yes_time_str
return None # except:
# return None
#
def get_data(numtime): def get_data(numtime):
try: try:
db = pymysql.connect(host="172.17.40.144", user='work', pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
passwd='oars152!traipseize738',
db="alpha", port=3306) cursor = pc.cursor()
cursor = db.cursor()
print("---------")
cursor.execute( cursor.execute(
"SELECT distinct(user_id),id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime) "SELECT distinct(user_id),id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() pc.close()
return user_id 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())
...@@ -120,7 +119,7 @@ if __name__ == "__main__": ...@@ -120,7 +119,7 @@ if __name__ == "__main__":
for i in time_list: for i in time_list:
numtime = time_conv(7 + 3 * i) numtime = time_convs(7 + 3 * i)
user_id = get_data(numtime) user_id = get_data(numtime)
...@@ -149,7 +148,7 @@ if __name__ == "__main__": ...@@ -149,7 +148,7 @@ if __name__ == "__main__":
time.sleep(random.randint(1, 10)) time.sleep(random.randint(1, 10))
cook = logins() cook = login()
if cook is not None: if cook is not None:
click(cook, rand_id) click(cook, rand_id)
......
...@@ -5,122 +5,123 @@ import pymysql ...@@ -5,122 +5,123 @@ import pymysql
import random import random
import traceback import traceback
import logging import logging
from auto_request import login, time_convs, reply, get_comment
auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create" from auto_request import host, user, port, db, passwd
def get_majia(): # auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
try:
data = open("/srv/apps/cybertron/batch_user_gen.txt")
# def get_majia():
list = [] # try:
# data = open("/srv/apps/cybertron/batch_user_gen.txt")
for i in data: #
list.append(i.strip('\n').strip(',')) # list = []
#
maj = random.randint(1, len(list)) # for i in data:
# list.append(i.strip('\n').strip(','))
user_id = list[maj - 1] #
# maj = random.randint(1, len(list))
return user_id #
# user_id = list[maj - 1]
except: #
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) # return user_id
return None #
# except:
# logging.error("catch exception,get_majia:%s" % traceback.format_exc())
def get_cookies(user_id): # return None
try: #
with open("/srv/apps/cybertron/user_session.txt", 'r') as f: #
try: # def get_cookies(user_id):
data = f.readlines() # try:
except: # with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
data = None # try:
# data = f.readlines()
list = [] # except:
for i in data: # data = None
list.append(i.strip('\n').split(",")) #
# list = []
for i in list: # for i in data:
# list.append(i.strip('\n').split(","))
if user_id == i[0]: #
return (i[1]) # for i in list:
except: #
# if user_id == i[0]:
return None # return (i[1])
# except:
#
def logins(): # return None
try: #
user_id = get_majia() #
# def logins():
cookies = get_cookies(user_id) # try:
# user_id = get_majia()
if cookies is not None: #
return {'sessionid': cookies} # cookies = get_cookies(user_id)
#
except: # if cookies is not None:
# return {'sessionid': cookies}
logging.error("catch exception,logins:%s" % traceback.format_exc()) #
# except:
return None #
# logging.error("catch exception,logins:%s" % traceback.format_exc())
#
def reply(cookies_get, id, content): # return None
try: #
post_dict = { #
'topic_id': id, # def reply(cookies_get, id, content):
'content': content # try:
} # post_dict = {
response = requests.post(url=auto_reply_url, # 'topic_id': id,
cookies=cookies_get, # 'content': content
data=post_dict) # }
# response = requests.post(url=auto_reply_url,
logging.info("response.text :%s" % (response.text)) # cookies=cookies_get,
# data=post_dict)
except: #
logging.error("catch exception,reply:%s" % traceback.format_exc()) # logging.info("response.text :%s" % (response.text))
#
# except:
def time_conv(numtime): # logging.error("catch exception,reply:%s" % traceback.format_exc())
try: #
now = datetime.datetime.now() #
yes_time = now - datetime.timedelta(days=numtime) # def time_conv(numtime):
yes_time_str = yes_time.strftime('%Y-%m-%d') # try:
return yes_time_str # now = datetime.datetime.now()
except: # yes_time = now - datetime.timedelta(days=numtime)
return None # yes_time_str = yes_time.strftime('%Y-%m-%d')
# return yes_time_str
# except:
# return None
# def get_comment():
# data = open("/srv/apps/cybertron/guanshui")
#
# list_guanshui = []
# for i in data:
# list_guanshui.append(i)
# num = random.randint(0, len(list_guanshui))
# comment = list_guanshui[num - 1]
# return comment
def get_topic_id(numtime): def get_topic_id(numtime):
try: try:
db = pymysql.connect(host="172.17.40.144", user='work', pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
passwd='oars152!traipseize738', cursor = pc.cursor()
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute( cursor.execute(
"SELECT distinct(user_id),id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0) " % numtime) "SELECT distinct(user_id),id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0) " % numtime)
data = cursor.fetchall() data = cursor.fetchall()
topic_id = list(data) topic_id = list(data)
logging.info("Database version : %s " % topic_id) logging.info("Database version : %s " % topic_id)
db.close() pc.close()
return topic_id return topic_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
def get_comment():
data = open("/srv/apps/cybertron/guanshui")
list_guanshui = []
for i in data:
list_guanshui.append(i)
num = random.randint(0, len(list_guanshui))
comment = list_guanshui[num - 1]
return comment
if __name__ == "__main__": if __name__ == "__main__":
try: try:
...@@ -129,7 +130,7 @@ if __name__ == "__main__": ...@@ -129,7 +130,7 @@ if __name__ == "__main__":
for i in time_list: for i in time_list:
numtime = time_conv(i) numtime = time_convs(i)
topic_id = get_topic_id(numtime) topic_id = get_topic_id(numtime)
...@@ -145,7 +146,6 @@ if __name__ == "__main__": ...@@ -145,7 +146,6 @@ if __name__ == "__main__":
else: else:
dicts[i[0]].append(i[1]) dicts[i[0]].append(i[1])
print(dicts)
for key, value in dicts.items(): for key, value in dicts.items():
...@@ -155,7 +155,7 @@ if __name__ == "__main__": ...@@ -155,7 +155,7 @@ if __name__ == "__main__":
time.sleep(random.randint(1, 10)) time.sleep(random.randint(1, 10))
cook = logins() cook = login()
if cook is not None: if cook is not None:
comment = get_comment() comment = get_comment()
......
...@@ -6,102 +6,103 @@ import random ...@@ -6,102 +6,103 @@ 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
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow" from auto_request import host, user, port, db, passwd
auto_pick_url = "http://earth.iyanzhi.com/api/v1/pick/do_pick"
# auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
#
def get_majia(): # auto_pick_url = "http://earth.iyanzhi.com/api/v1/pick/do_pick"
try: #
data = open("/srv/apps/cybertron/batch_user_gen") #
# def get_majia():
list = [] # try:
# data = open("/srv/apps/cybertron/batch_user_gen")
for i in data: #
list.append(i.strip('\n').strip(',')) # list = []
#
maj = random.randint(1, len(list)) # for i in data:
# list.append(i.strip('\n').strip(','))
user_id = list[maj - 1] #
# maj = random.randint(1, len(list))
return user_id #
# user_id = list[maj - 1]
except: #
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) # return user_id
return None #
# except:
# logging.error("catch exception,get_majia:%s" % traceback.format_exc())
def get_cookies(user_id): # return None
try: #
with open("/srv/apps/cybertron/user_session.txt", 'r') as f: #
try: # def get_cookies(user_id):
data = f.readlines() # try:
except: # with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
data = None # try:
# data = f.readlines()
list = [] # except:
for i in data: # data = None
list.append(i.strip('\n').split(",")) #
# list = []
for i in list: # for i in data:
# list.append(i.strip('\n').split(","))
if user_id == i[0]: #
return (i[1]) # for i in list:
except: #
# if user_id == i[0]:
return None # return (i[1])
# except:
#
def logins(): # return None
try: #
user_id = get_majia() #
# def logins():
cookies = get_cookies(user_id) # try:
# user_id = get_majia()
if cookies is not None: #
return {'sessionid': cookies} # cookies = get_cookies(user_id)
#
except: # if cookies is not None:
# return {'sessionid': cookies}
logging.error("catch exception,logins:%s" % traceback.format_exc()) #
# except:
return None #
# logging.error("catch exception,logins:%s" % traceback.format_exc())
#
def follow(cookies_get, id): # return None
try: #
post_dict = { #
'type': 1, # def follow(cookies_get, id):
'id': id # try:
} # post_dict = {
response = requests.post(url=auto_follow_url, # 'type': 1,
cookies=cookies_get, # 'id': id
data=post_dict) # }
# response = requests.post(url=auto_follow_url,
logging.info("response.text:%s" % response.text) # cookies=cookies_get,
# data=post_dict)
except: #
# logging.info("response.text:%s" % response.text)
logging.error("catch exception,logins:%s" % traceback.format_exc()) #
# except:
#
def time_conv(numtime): # logging.error("catch exception,logins:%s" % traceback.format_exc())
try: #
now = datetime.datetime.now() #
yes_time = now - datetime.timedelta(days=numtime) # def time_conv(numtime):
yes_time_str = yes_time.strftime('%Y-%m-%d') # try:
return yes_time_str # now = datetime.datetime.now()
except: # yes_time = now - datetime.timedelta(days=numtime)
return None # yes_time_str = yes_time.strftime('%Y-%m-%d')
# return yes_time_str
# except:
# return None
def get_topic_new_user(numtime): def get_topic_new_user(numtime):
try: try:
db = pymysql.connect(host="172.17.40.144", user='work', pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
passwd='oars152!traipseize738', cursor = pc.cursor()
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute( cursor.execute(
"SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime) "SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
topic_data = cursor.fetchall() topic_data = cursor.fetchall()
...@@ -117,7 +118,7 @@ def get_topic_new_user(numtime): ...@@ -117,7 +118,7 @@ def get_topic_new_user(numtime):
for i in new_user_data: for i in new_user_data:
user_id.append(i) user_id.append(i)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() pc.close()
return user_id 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())
...@@ -127,7 +128,7 @@ def get_topic_new_user(numtime): ...@@ -127,7 +128,7 @@ def get_topic_new_user(numtime):
if __name__ == "__main__": if __name__ == "__main__":
try: try:
numtime = time_conv(0) numtime = time_convs(0)
user_id = get_topic_new_user(numtime) user_id = get_topic_new_user(numtime)
...@@ -141,7 +142,7 @@ if __name__ == "__main__": ...@@ -141,7 +142,7 @@ if __name__ == "__main__":
time.sleep(random.randint(10, 30)) time.sleep(random.randint(10, 30))
cookies = logins() cookies = login()
if cookies is not None: if cookies is not None:
follow(cookies, id) follow(cookies, id)
......
...@@ -6,124 +6,131 @@ import random ...@@ -6,124 +6,131 @@ import random
import traceback import traceback
from log_settings import * from log_settings import *
import logging import logging
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow" from auto_request import login, time_convs, follow
from auto_request import host, user, port, db, passwd
# auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
#
#
#
# def get_majia():
#
# try:
# data = open("/srv/apps/cybertron/batch_user_gen")
#
# list=[]
#
# for i in data:
# list.append(i.strip('\n').strip(','))
#
# maj = random.randint(1,len(list))
#
# user_id=list[maj-1]
#
# return user_id
#
# except:
# logging.error("catch exception,get_majia:%s" % traceback.format_exc())
# return None
#
# def get_cookies(user_id):
#
# try:
# with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
# try:
# data = f.readlines()
# except:
# data = None
#
# list = []
# for i in data:
# list.append(i.strip('\n').split(","))
#
# for i in list:
#
# if user_id == i[0]:
#
# return (i[1])
# except:
#
# return None
#
# def logins():
#
# try:
# user_id=get_majia()
#
# cookies = get_cookies(user_id)
#
# if cookies is not None:
#
# return {'sessionid': cookies}
#
# except:
#
# logging.error("catch exception,logins:%s" % traceback.format_exc())
#
# return None
#
# def follow(cookies_get, id):
#
# try:
# post_dict = {
# 'type': 1,
# 'id': id
# }
# response = requests.post(url=auto_follow_url,
# cookies=cookies_get,
# data=post_dict)
#
# logging.info("response.text:%s" % response.text)
#
# except:
#
# logging.error("catch exception,logins:%s" % traceback.format_exc())
#
# def time_conv(numtime):
# try:
# now = datetime.datetime.now()
# yes_time = now - datetime.timedelta(days=numtime)
# yes_time_str = yes_time.strftime('%Y-%m-%d')
# return yes_time_str
# except:
# return None
def get_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list))
user_id=list[maj-1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def logins():
try:
user_id=get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_data(numtime): def get_data(numtime):
try: try:
db = pymysql.connect(host="172.17.40.144", user='work', pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
passwd='oars152!traipseize738', cursor = pc.cursor()
db="alpha", port=3306) cursor.execute(
cursor = db.cursor() "SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
cursor.execute("SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() pc.close()
return user_id 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
if __name__ == "__main__": if __name__ == "__main__":
try: try:
time_list = [1,2,3,4,5,6,7,11] time_list = [1, 2, 3, 4, 5, 6, 7, 11]
for i in range(len(time_list)): for i in range(len(time_list)):
if time_list[i] != 11: if time_list[i] != 11:
numtime = time_conv(time_list[i]) numtime = time_convs(time_list[i])
user_id = get_data(numtime) user_id = get_data(numtime)
follow_num = random.randint(1,2) follow_num = random.randint(1, 2)
for i in range(follow_num): for i in range(follow_num):
...@@ -131,16 +138,15 @@ if __name__ == "__main__": ...@@ -131,16 +138,15 @@ if __name__ == "__main__":
id = int(j[0]) id = int(j[0])
time.sleep(random.randint(1,10)) time.sleep(random.randint(1, 10))
cookies=logins() cookies = login()
if cookies is not None: if cookies is not None:
follow(cookies, id) follow(cookies, id)
time.sleep(300) time.sleep(300)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -7,86 +7,86 @@ import pandas as pd ...@@ -7,86 +7,86 @@ import pandas as pd
import traceback import traceback
from log_settings import * from log_settings import *
import logging import logging
from auto_request import login, time_conv, follow
auto_click_url = "http://earth.iyanzhi.com/api/v1/like" from auto_request import host, user, port, db, passwd
auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
# auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
# auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
def get_cookies(user_id): # auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
try: #
with open("/srv/apps/cybertron/user_session.txt", 'r') as f: #
try: # def get_cookies(user_id):
data = f.readlines() # try:
except: # with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
data = None # try:
# data = f.readlines()
list = [] # except:
for i in data: # data = None
list.append(i.strip('\n').split(",")) #
# list = []
for i in list: # for i in data:
# list.append(i.strip('\n').split(","))
if user_id == i[0]: #
return (i[1]) # for i in list:
except: #
# if user_id == i[0]:
return None # return (i[1])
# except:
#
def logins(user_id): # return None
try: #
cookies = get_cookies(user_id) #
# def logins(user_id):
if cookies is not None: # try:
return {'sessionid': cookies} # cookies = get_cookies(user_id)
#
except: # if cookies is not None:
# return {'sessionid': cookies}
logging.error("catch exception,logins:%s" % traceback.format_exc()) #
# except:
return None #
# logging.error("catch exception,logins:%s" % traceback.format_exc())
#
def follow(cookies_get, id): # return None
try: #
post_dict = { #
'type': 1, # def follow(cookies_get, id):
'id': id # try:
} # post_dict = {
response = requests.post(url=auto_follow_url, # 'type': 1,
cookies=cookies_get, # 'id': id
data=post_dict) # }
# response = requests.post(url=auto_follow_url,
logging.info("response.text:%s" % response.text) # cookies=cookies_get,
# data=post_dict)
except: #
# logging.info("response.text:%s" % response.text)
logging.error("catch exception,logins:%s" % traceback.format_exc()) #
# except:
#
def time_conv(): # logging.error("catch exception,logins:%s" % traceback.format_exc())
try: #
now = datetime.datetime.now() #
yes_time = now - datetime.timedelta(minutes=15) # def time_conv():
return yes_time # try:
except: # now = datetime.datetime.now()
return None # yes_time = now - datetime.timedelta(minutes=15)
# return yes_time
# except:
# return None
def get_follw_majia(numtime): def get_follw_majia(numtime):
try: try:
db = pymysql.connect(host="172.17.40.144", user='work', pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
passwd='oars152!traipseize738', cursor = pc.cursor()
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute( cursor.execute(
"select temp1.user_id,temp1.email,temp2.user_id from account_user_auth temp1 left join (select user_id,follow_id,create_time from user_follow) temp2 on temp1.user_id = temp2.follow_id where temp1.email in ('s_05tmwu@shadow.com','s_07CRHt@shadow.com','s_0bdxxU@shadow.com','s_0mfxcO@shadow.com','s_0u6eaV@shadow.com','s_0UudEr@shadow.com','s_1b3v5V@shadow.com','s_ZVuLyC@shadow.com','s_1dbAoA@shadow.com','s_1dholX@shadow.com','s_1EpLlt@shadow.com') and temp2.create_time like '%%%%%s%%%%' " % ( "select temp1.user_id,temp1.email,temp2.user_id from account_user_auth temp1 left join (select user_id,follow_id,create_time from user_follow) temp2 on temp1.user_id = temp2.follow_id where temp1.email in ('s_05tmwu@shadow.com','s_07CRHt@shadow.com','s_0bdxxU@shadow.com','s_0mfxcO@shadow.com','s_0u6eaV@shadow.com','s_0UudEr@shadow.com','s_1b3v5V@shadow.com','s_ZVuLyC@shadow.com','s_1dbAoA@shadow.com','s_1dholX@shadow.com','s_1EpLlt@shadow.com') and temp2.create_time like '%%%%%s%%%%' " % (
numtime)) numtime))
data = cursor.fetchall() data = cursor.fetchall()
data = list(data) data = list(data)
logging.info("Database version : %s " % data) logging.info("Database version : %s " % data)
db.close() pc.close()
return data return data
except: except:
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
...@@ -99,8 +99,6 @@ if __name__ == "__main__": ...@@ -99,8 +99,6 @@ if __name__ == "__main__":
numtime = time_conv() numtime = time_conv()
# get majia zhanghao
data = get_follw_majia(numtime) data = get_follw_majia(numtime)
dict_follow_id = {} dict_follow_id = {}
...@@ -139,7 +137,7 @@ if __name__ == "__main__": ...@@ -139,7 +137,7 @@ if __name__ == "__main__":
for i in value: for i in value:
cookies = logins(id) cookies = login(id)
if cookies is not None: if cookies is not None:
follow(cookies, i) follow(cookies, i)
......
...@@ -6,99 +6,101 @@ import random ...@@ -6,99 +6,101 @@ 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 host, user, port, db, passwd
# auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
#
#
# def get_majia():
# try:
# data = open("/srv/apps/cybertron/batch_user_gen")
#
# list = []
#
# for i in data:
# list.append(i.strip('\n').strip(','))
#
# maj = random.randint(1, len(list))
#
# user_id = list[maj - 1]
#
# return user_id
#
# except:
# logging.error("catch exception,get_majia:%s" % traceback.format_exc())
# return None
#
#
# def get_cookies(user_id):
# try:
# with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
# try:
# data = f.readlines()
# except:
# data = None
#
# list = []
# for i in data:
# list.append(i.strip('\n').split(","))
#
# for i in list:
#
# if user_id == i[0]:
# return (i[1])
# except:
#
# return None
#
#
# def logins():
# try:
# user_id = get_majia()
#
# cookies = get_cookies(user_id)
#
# if cookies is not None:
# return {'sessionid': cookies}
#
# except:
#
# logging.error("catch exception,logins:%s" % traceback.format_exc())
#
# return None
#
#
# def follow(cookies_get, id):
# try:
# post_dict = {
# 'type': 1,
# 'id': id
# }
# response = requests.post(url=auto_follow_url,
# cookies=cookies_get,
# data=post_dict)
#
# logging.info("response.text:%s" % response.text)
#
# except:
#
# logging.error("catch exception,logins:%s" % traceback.format_exc())
#
#
# def time_conv(numtime):
# try:
# now = datetime.datetime.now()
# yes_time = now - datetime.timedelta(days=numtime)
# yes_time_str = yes_time.strftime('%Y-%m-%d')
# return yes_time_str
# except:
# return None
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
def get_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list = []
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1, len(list))
user_id = list[maj - 1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def logins():
try:
user_id = get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_commnet_id(numtime): def get_commnet_id(numtime):
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738', pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
db="alpha", port=3306) cursor = pc.cursor()
cursor = db.cursor()
cursor.execute( cursor.execute(
"SELECT user_id FROM reply WHERE create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime) "SELECT user_id FROM reply WHERE create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
...@@ -155,7 +157,7 @@ def get_commnet_id(numtime): ...@@ -155,7 +157,7 @@ def get_commnet_id(numtime):
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() pc.close()
return user_id return user_id
...@@ -164,7 +166,7 @@ if __name__ == "__main__": ...@@ -164,7 +166,7 @@ if __name__ == "__main__":
try: try:
numtime = time_conv(1) numtime = time_convs(1)
user_id = get_commnet_id(numtime) user_id = get_commnet_id(numtime)
...@@ -178,7 +180,7 @@ if __name__ == "__main__": ...@@ -178,7 +180,7 @@ if __name__ == "__main__":
time.sleep(random.randint(10, 50)) time.sleep(random.randint(10, 50))
cookies = logins() cookies = login()
if cookies is not None: if cookies is not None:
follow(cookies, id) follow(cookies, id)
......
...@@ -6,102 +6,106 @@ import random ...@@ -6,102 +6,106 @@ import random
import traceback import traceback
from log_settings import * from log_settings import *
import logging import logging
from auto_request import login, time_conv, follow,get_cookies
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow" from auto_request import host, user, port, db, passwd
def get_majia():
#
try: # auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
data = open("/srv/apps/cybertron/batch_user_gen") #
# def get_majia():
list=[] #
# try:
for i in data: # data = open("/srv/apps/cybertron/batch_user_gen")
list.append(i.strip('\n').strip(',')) #
# list=[]
maj = random.randint(1,len(list)) #
# for i in data:
user_id=list[maj-1] # list.append(i.strip('\n').strip(','))
#
return user_id # maj = random.randint(1,len(list))
#
except: # user_id=list[maj-1]
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) #
return None # return user_id
#
def get_cookies(user_id): # except:
# logging.error("catch exception,get_majia:%s" % traceback.format_exc())
try: # return None
with open("/srv/apps/cybertron/user_session.txt", 'r') as f: #
try: # def get_cookies(user_id):
data = f.readlines() #
except: # try:
data = None # with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
# try:
list = [] # data = f.readlines()
for i in data: # except:
list.append(i.strip('\n').split(",")) # data = None
#
for i in list: # list = []
# for i in data:
if user_id == i[0]: # list.append(i.strip('\n').split(","))
#
return (i[1]) # for i in list:
except: #
# if user_id == i[0]:
return None #
# return (i[1])
def logins(): # except:
#
try: # return None
user_id=get_majia() #
# def logins():
cookies = get_cookies(user_id) #
# try:
if cookies is not None: # user_id=get_majia()
#
return {'sessionid': cookies} # cookies = get_cookies(user_id)
#
except: # if cookies is not None:
#
logging.error("catch exception,logins:%s" % traceback.format_exc()) # return {'sessionid': cookies}
#
return None # except:
#
def follow(cookies_get, id): # logging.error("catch exception,logins:%s" % traceback.format_exc())
try: #
post_dict = { # return None
'type': 1, #
'id': id # def follow(cookies_get, id):
} # try:
response = requests.post(url=auto_follow_url, # post_dict = {
cookies=cookies_get, # 'type': 1,
data=post_dict) # 'id': id
# }
logging.info("response.text:%s" % response.text) # response = requests.post(url=auto_follow_url,
# cookies=cookies_get,
except: # data=post_dict)
#
logging.error("catch exception,logins:%s" % traceback.format_exc()) # logging.info("response.text:%s" % response.text)
#
def time_conv(numtime): # except:
try: #
now = datetime.datetime.now() # logging.error("catch exception,logins:%s" % traceback.format_exc())
yes_time = now - datetime.timedelta(days=numtime) #
yes_time_str = yes_time.strftime('%Y-%m-%d') # def time_conv(numtime):
return yes_time_str # try:
except: # now = datetime.datetime.now()
return None # yes_time = now - datetime.timedelta(days=numtime)
# yes_time_str = yes_time.strftime('%Y-%m-%d')
# return yes_time_str
# except:
# return None
def get_data(numtime): def get_data(numtime):
try: try:
db = pymysql.connect(host="172.17.40.144", user='work',passwd='oars152!traipseize738',db="alpha", port=3306) pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = db.cursor() cursor = pc.cursor()
cursor.execute("select 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 ) and user_id in (select user_id from user_extra where is_shadow = 0)" ,(numtime)) cursor.execute("select 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 ) and user_id in (select user_id from user_extra where is_shadow = 0)" ,(numtime))
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() pc.close()
return user_id 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())
...@@ -123,7 +127,7 @@ if __name__ == "__main__": ...@@ -123,7 +127,7 @@ if __name__ == "__main__":
time.sleep(random.randint(1, 10)) time.sleep(random.randint(1, 10))
cook=logins() cook=login()
if cook is not None: if cook is not None:
......
...@@ -6,106 +6,106 @@ import random ...@@ -6,106 +6,106 @@ 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
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow" from auto_request import host,user,port,db,passwd
# auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
def get_majia(): #
try: #
data = open("/srv/apps/cybertron/batch_user_gen") # def get_majia():
# try:
list = [] # data = open("/srv/apps/cybertron/batch_user_gen")
#
for i in data: # list = []
list.append(i.strip('\n').strip(',')) #
# for i in data:
maj = random.randint(1, len(list)) # list.append(i.strip('\n').strip(','))
#
user_id = list[maj - 1] # maj = random.randint(1, len(list))
#
return user_id # user_id = list[maj - 1]
#
except: # return user_id
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) #
return None # except:
# logging.error("catch exception,get_majia:%s" % traceback.format_exc())
# return None
def get_cookies(user_id): #
try: #
with open("/srv/apps/cybertron/user_session.txt", 'r') as f: # def get_cookies(user_id):
try: # try:
data = f.readlines() # with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
except: # try:
data = None # data = f.readlines()
# except:
list = [] # data = None
for i in data: #
list.append(i.strip('\n').split(",")) # list = []
# for i in data:
for i in list: # list.append(i.strip('\n').split(","))
#
if user_id == i[0]: # for i in list:
return (i[1]) #
except: # if user_id == i[0]:
# return (i[1])
return None # except:
#
# return None
def logins(): #
try: #
user_id = get_majia() # def logins():
# try:
cookies = get_cookies(user_id) # user_id = get_majia()
#
if cookies is not None: # cookies = get_cookies(user_id)
return {'sessionid': cookies} #
# if cookies is not None:
except: # return {'sessionid': cookies}
#
logging.error("catch exception,logins:%s" % traceback.format_exc()) # except:
#
return None # logging.error("catch exception,logins:%s" % traceback.format_exc())
#
# return None
def follow(cookies_get, id): #
try: #
post_dict = { # def follow(cookies_get, id):
'type': 1, # try:
'id': id # post_dict = {
} # 'type': 1,
response = requests.post(url=auto_follow_url, # 'id': id
cookies=cookies_get, # }
data=post_dict) # response = requests.post(url=auto_follow_url,
# cookies=cookies_get,
logging.info("response.text:%s" % response.text) # data=post_dict)
#
except: # logging.info("response.text:%s" % response.text)
#
logging.error("catch exception,logins:%s" % traceback.format_exc()) # except:
#
# logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime): #
try: #
now = datetime.datetime.now() # def time_conv(numtime):
yes_time = now - datetime.timedelta(days=numtime) # try:
yes_time_str = yes_time.strftime('%Y-%m-%d') # now = datetime.datetime.now()
return yes_time_str # yes_time = now - datetime.timedelta(days=numtime)
except: # yes_time_str = yes_time.strftime('%Y-%m-%d')
return None # return yes_time_str
# except:
# return None
def get_data(numtime): def get_data(numtime):
try: try:
db = pymysql.connect(host="172.17.40.144", user='work', pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
passwd='oars152!traipseize738', cursor = pc.cursor()
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute( cursor.execute(
"select user_id from pv_maidian where page_name ='home' and partiton_date like '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime) "select user_id from pv_maidian where page_name ='home' and partiton_date like '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.pcinfo("Database version : %s " % user_id)
db.close() pc.close()
return user_id 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())
...@@ -114,7 +114,7 @@ def get_data(numtime): ...@@ -114,7 +114,7 @@ def get_data(numtime):
if __name__ == "__main__": if __name__ == "__main__":
try: try:
numtime = time_conv(1) numtime = time_convs(1)
user_id = get_data(numtime) user_id = get_data(numtime)
urge_num = random.randint(0, 1) urge_num = random.randint(0, 1)
...@@ -125,10 +125,12 @@ if __name__ == "__main__": ...@@ -125,10 +125,12 @@ if __name__ == "__main__":
time.sleep(random.randint(1, 10)) time.sleep(random.randint(1, 10))
cook = logins() cook = login()
if cook is not None: if cook is not None:
follow(cook, id) follow(cook, id)
time.sleep(300) time.sleep(300)
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 pandas as pd
import traceback
from log_settings import *
import logging
import pymysql
import logging
import log_settings
import traceback
# auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
# auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
# auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
# auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
auto_click_url = "http://earth.igengmei.com/api/v1/like"
auto_reply_url = "http://earth.igengmei.com/api/v1/reply/create"
auto_follow_url = "http://earth.igengmei.com/api/v1/follow"
auto_urge_url = "http://earth.igengmei.com/api/v1/user/urge"
# host = "172.17.40.144"
# user = "work"
# passwd = 'oars152!traipseize738'
# db = "alpha"
# port = 3306
host = "rm-2zeaut61u9sm21m0b.mysql.rds.aliyuncs.com"
user = 'work'
passwd = 'Gengmei123'
db = "alpha"
port = '3306'
def get_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list = []
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1, len(list))
user_id = list[maj - 1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def login():
try:
user_id = get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def click(cookies_get, id):
try:
post_dict = {
'type': 0,
'id': id
}
response = requests.post(url=auto_click_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def reply(cookies_get, id, content):
try:
post_dict = {
'topic_id': id,
'content': content
}
response = requests.post(url=auto_reply_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(minutest):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(minutes=minutest)
print(yes_time)
return yes_time
except:
return None
def time_convs(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_comment():
try:
data = open("/srv/apps/cybertron/guanshui", "r")
list_guanshui = []
for i in data:
list_guanshui.append(i)
num = random.randint(0, len(list_guanshui))
comment = list_guanshui[num - 1]
return comment
except:
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def Urge(cookies_get, id):
try:
post_dict = {
'id': id
}
response = requests.post(url=auto_urge_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
...@@ -6,127 +6,127 @@ import random ...@@ -6,127 +6,127 @@ import random
import traceback import traceback
from log_settings import * from log_settings import *
import logging import logging
from auto_request import login, time_conv, follow,click
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow" from auto_request import host, user, port, db, passwd
auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
# auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
#
def get_majia(): # auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
try: #
data = open("/srv/apps/cybertron/batch_user_gen") #
# def get_majia():
list = [] # try:
# data = open("/srv/apps/cybertron/batch_user_gen")
for i in data: #
list.append(i.strip('\n').strip(',')) # list = []
#
maj = random.randint(1, len(list)) # for i in data:
# list.append(i.strip('\n').strip(','))
user_id = list[maj - 1] #
# maj = random.randint(1, len(list))
return user_id #
# user_id = list[maj - 1]
except: #
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) # return user_id
return None #
# except:
# logging.error("catch exception,get_majia:%s" % traceback.format_exc())
def get_cookies(user_id): # return None
try: #
with open("/srv/apps/cybertron/user_session.txt", 'r') as f: #
try: # def get_cookies(user_id):
data = f.readlines() # try:
except: # with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
data = None # try:
# data = f.readlines()
list = [] # except:
for i in data: # data = None
list.append(i.strip('\n').split(",")) #
# list = []
for i in list: # for i in data:
# list.append(i.strip('\n').split(","))
if user_id == i[0]: #
return (i[1]) # for i in list:
except: #
# if user_id == i[0]:
return None # return (i[1])
# except:
#
def logins(): # return None
try: #
user_id = get_majia() #
# def logins():
cookies = get_cookies(user_id) # try:
# user_id = get_majia()
if cookies is not None: #
return {'sessionid': cookies} # cookies = get_cookies(user_id)
#
except: # if cookies is not None:
# return {'sessionid': cookies}
logging.error("catch exception,logins:%s" % traceback.format_exc()) #
# except:
return None #
# logging.error("catch exception,logins:%s" % traceback.format_exc())
#
def click(cookies_get, id): # return None
try: #
post_dict = { #
'type': 0, # def click(cookies_get, id):
'id': id # try:
} # post_dict = {
response = requests.post(url=auto_click_url, # 'type': 0,
cookies=cookies_get, # 'id': id
data=post_dict) # }
# response = requests.post(url=auto_click_url,
logging.info("response.text:%s" % response.text) # cookies=cookies_get,
# data=post_dict)
except: #
# logging.info("response.text:%s" % response.text)
logging.error("catch exception,logins:%s" % traceback.format_exc()) #
# except:
#
def follow(cookies_get, id): # logging.error("catch exception,logins:%s" % traceback.format_exc())
try: #
post_dict = { #
'type': 1, # def follow(cookies_get, id):
'id': id # try:
} # post_dict = {
response = requests.post(url=auto_follow_url, # 'type': 1,
cookies=cookies_get, # 'id': id
data=post_dict) # }
# response = requests.post(url=auto_follow_url,
print(response.text, 'url') # cookies=cookies_get,
# data=post_dict)
logging.info("response.text:%s" % response.text) #
# print(response.text, 'url')
except: #
# logging.info("response.text:%s" % response.text)
logging.error("catch exception,logins:%s" % traceback.format_exc()) #
# except:
#
def time_conv(numtime): # logging.error("catch exception,logins:%s" % traceback.format_exc())
try: #
now = datetime.datetime.now() #
yes_time = now - datetime.timedelta(days=numtime) # def time_conv(numtime):
yes_time_str = yes_time.strftime('%Y-%m-%d') # try:
return yes_time_str # now = datetime.datetime.now()
except: # yes_time = now - datetime.timedelta(days=numtime)
return None # yes_time_str = yes_time.strftime('%Y-%m-%d')
# return yes_time_str
# except:
# return None
def get_star_user_id(numtime): def get_star_user_id(numtime):
try: try:
db = pymysql.connect(host="172.17.40.144", user='work', pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
passwd='oars152!traipseize738', cursor = pc.cursor()
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute( cursor.execute(
"SELECT user_id FROM topic WHERE is_online=1 and (content_level =4 or content_level =5) and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime) "SELECT user_id FROM topic WHERE is_online=1 and (content_level =4 or content_level =5) and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() pc.close()
return user_id 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())
...@@ -135,16 +135,14 @@ def get_star_user_id(numtime): ...@@ -135,16 +135,14 @@ def get_star_user_id(numtime):
def get_star_topic_id(numtime): def get_star_topic_id(numtime):
try: try:
db = pymysql.connect(host="172.17.40.144", user='work', pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
passwd='oars152!traipseize738', cursor = pc.cursor()
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute( cursor.execute(
"SELECT id FROM topic WHERE is_online=1 and (content_level =4 or content_level =5) and create_time LIKE '%%%%%s%%%%'" % numtime) "SELECT id FROM topic WHERE is_online=1 and (content_level =4 or content_level =5) and create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() pc.close()
return user_id 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())
...@@ -171,9 +169,10 @@ if __name__ == "__main__": ...@@ -171,9 +169,10 @@ if __name__ == "__main__":
time.sleep(random.randint(1, 10)) time.sleep(random.randint(1, 10))
cookies = logins() cookies = login()
if cookies is not None: if cookies is not None:
click(cookies, id) click(cookies, id)
time.sleep(300) time.sleep(300)
...@@ -189,7 +188,7 @@ if __name__ == "__main__": ...@@ -189,7 +188,7 @@ if __name__ == "__main__":
time.sleep(random.randint(1, 10)) time.sleep(random.randint(1, 10))
cookies = logins() cookies = login()
if cookies is not None: if cookies is not None:
follow(cookies, id) follow(cookies, id)
......
...@@ -7,108 +7,110 @@ import pandas as pd ...@@ -7,108 +7,110 @@ import pandas as pd
import traceback import traceback
from log_settings import * from log_settings import *
import logging import logging
auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge" from auto_request import login, time_conv, Urge
from auto_request import host, user, port, db, passwd
def get_majia():
try: # auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
data = open("/srv/apps/cybertron/batch_user_gen")
# def get_majia():
list=[] #
# try:
for i in data: # data = open("/srv/apps/cybertron/batch_user_gen")
#
list.append(i.strip('\n').strip(',')) # list=[]
#
maj = random.randint(1,len(list)) # for i in data:
#
user_id=list[maj-1] # list.append(i.strip('\n').strip(','))
#
return user_id # maj = random.randint(1,len(list))
#
except: # user_id=list[maj-1]
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) #
return None # return user_id
#
def get_cookies(user_id): # except:
# logging.error("catch exception,get_majia:%s" % traceback.format_exc())
try: # return None
with open("/srv/apps/cybertron/user_session.txt", 'r') as f: #
try: # def get_cookies(user_id):
data = f.readlines() #
except: # try:
data = None # with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
# try:
list = [] # data = f.readlines()
for i in data: # except:
list.append(i.strip('\n').split(",")) # data = None
#
for i in list: # list = []
# for i in data:
if user_id == i[0]: # list.append(i.strip('\n').split(","))
#
return (i[1]) # for i in list:
except: #
# if user_id == i[0]:
return None #
# return (i[1])
# except:
def logins(): #
# return None
try: #
user_id=get_majia() #
# def logins():
cookies = get_cookies(user_id) #
# try:
if cookies is not None: # user_id=get_majia()
#
return {'sessionid': cookies} # cookies = get_cookies(user_id)
#
except: # if cookies is not None:
#
logging.error("catch exception,logins:%s" % traceback.format_exc()) # return {'sessionid': cookies}
#
return None # except:
#
def Urge(cookies_get, id): # logging.error("catch exception,logins:%s" % traceback.format_exc())
#
try: # return None
post_dict = { #
'id': id # def Urge(cookies_get, id):
} #
response = requests.post(url=auto_urge_url, # try:
cookies=cookies_get, # post_dict = {
data=post_dict) # 'id': id
# }
logging.info("response.text:%s" % response.text) # response = requests.post(url=auto_urge_url,
# cookies=cookies_get,
except: # data=post_dict)
#
logging.error("catch exception,logins:%s" % traceback.format_exc()) # logging.info("response.text:%s" % response.text)
#
def time_conv(numtime): # except:
#
try: # logging.error("catch exception,logins:%s" % traceback.format_exc())
now = datetime.datetime.now() #
yes_time = now - datetime.timedelta(days=numtime) # def time_conv(numtime):
yes_time_str = yes_time.strftime('%Y-%m-%d') #
return yes_time_str # try:
except: # now = datetime.datetime.now()
return None # yes_time = now - datetime.timedelta(days=numtime)
# yes_time_str = yes_time.strftime('%Y-%m-%d')
# return yes_time_str
# except:
# return None
def get_star_useid(numtime): def get_star_useid(numtime):
try: try:
db = pymysql.connect(host="172.17.40.144", user='work', pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
passwd='oars152!traipseize738', cursor = pc.cursor()
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute( cursor.execute(
"SELECT user_id FROM topic WHERE is_online=1 and (content_level =4 or content_level =5) and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime) "SELECT user_id FROM topic WHERE is_online=1 and (content_level =4 or content_level =5) and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() pc.close()
return user_id return user_id
except: except:
...@@ -135,7 +137,7 @@ if __name__ == "__main__": ...@@ -135,7 +137,7 @@ if __name__ == "__main__":
time.sleep(random.randint(10, 50)) time.sleep(random.randint(10, 50))
cookies = logins() cookies = login()
if cookies is not None: if cookies is not None:
......
...@@ -7,107 +7,107 @@ import pandas as pd ...@@ -7,107 +7,107 @@ import pandas as pd
import traceback import traceback
from log_settings import * from log_settings import *
import logging import logging
auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge" from auto_request import login, time_conv, Urge
from auto_request import host, user, port, db, passwd
def get_majia():
# auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
try: #
data = open("/srv/apps/cybertron/batch_user_gen") # def get_majia():
#
list=[] # try:
# data = open("/srv/apps/cybertron/batch_user_gen")
for i in data: #
list.append(i.strip('\n').strip(',')) # list=[]
#
maj = random.randint(1,len(list)) # for i in data:
# list.append(i.strip('\n').strip(','))
user_id=list[maj-1] #
# maj = random.randint(1,len(list))
return user_id #
# user_id=list[maj-1]
except: #
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) # return user_id
return None #
# except:
def get_cookies(user_id): # logging.error("catch exception,get_majia:%s" % traceback.format_exc())
# return None
try: #
with open("/srv/apps/cybertron/user_session.txt", 'r') as f: # def get_cookies(user_id):
try: #
data = f.readlines() # try:
except: # with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
data = None # try:
# data = f.readlines()
list = [] # except:
for i in data: # data = None
list.append(i.strip('\n').split(",")) #
# list = []
for i in list: # for i in data:
# list.append(i.strip('\n').split(","))
if user_id == i[0]: #
# for i in list:
return (i[1]) #
except: # if user_id == i[0]:
#
return None # return (i[1])
# except:
#
def logins(): # return None
#
try: #
user_id=get_majia() # def logins():
#
cookies = get_cookies(user_id) # try:
# user_id=get_majia()
if cookies is not None: #
# cookies = get_cookies(user_id)
return {'sessionid': cookies} #
# if cookies is not None:
except: #
# return {'sessionid': cookies}
logging.error("catch exception,logins:%s" % traceback.format_exc()) #
# except:
return None #
# logging.error("catch exception,logins:%s" % traceback.format_exc())
def Urge(cookies_get, id): #
# return None
try: #
post_dict = { # def Urge(cookies_get, id):
'id': id #
} # try:
response = requests.post(url=auto_urge_url, # post_dict = {
cookies=cookies_get, # 'id': id
data=post_dict) # }
# response = requests.post(url=auto_urge_url,
logging.info("response.text:%s" % response.text) # cookies=cookies_get,
# data=post_dict)
except: #
# logging.info("response.text:%s" % response.text)
logging.error("catch exception,logins:%s" % traceback.format_exc()) #
# except:
def time_conv(numtime): #
# logging.error("catch exception,logins:%s" % traceback.format_exc())
try: #
now = datetime.datetime.now() # def time_conv(numtime):
yes_time = now - datetime.timedelta(days=numtime) #
yes_time_str = yes_time.strftime('%Y-%m-%d') # try:
return yes_time_str # now = datetime.datetime.now()
except: # yes_time = now - datetime.timedelta(days=numtime)
return None # yes_time_str = yes_time.strftime('%Y-%m-%d')
# return yes_time_str
# except:
# return None
#
def get_data(numtime): def get_data(numtime):
try: try:
db = pymysql.connect(host="172.17.40.144", user='work', pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
passwd='oars152!traipseize738', cursor = pc.cursor()
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute("SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime) cursor.execute("SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() pc.close()
return user_id 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())
...@@ -135,7 +135,7 @@ if __name__ == "__main__": ...@@ -135,7 +135,7 @@ if __name__ == "__main__":
time.sleep(random.randint(3, 10)) time.sleep(random.randint(3, 10))
cookies=logins() cookies=login()
if cookies is not None: if cookies is not None:
......
...@@ -7,105 +7,105 @@ import traceback ...@@ -7,105 +7,105 @@ import traceback
from log_settings import * from log_settings import *
import logging import logging
auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge" from auto_request import login, time_conv, Urge
from auto_request import host, user, port, db, passwd
def get_majia(): # auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
try: #
data = open("/srv/apps/cybertron/batch_user_gen") # def get_majia():
# try:
list = [] # data = open("/srv/apps/cybertron/batch_user_gen")
#
for i in data: # list = []
list.append(i.strip('\n').strip(',')) #
# for i in data:
maj = random.randint(1, len(list)) # list.append(i.strip('\n').strip(','))
#
user_id = list[maj - 1] # maj = random.randint(1, len(list))
#
return user_id # user_id = list[maj - 1]
#
except: # return user_id
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) #
return None # except:
# logging.error("catch exception,get_majia:%s" % traceback.format_exc())
# return None
def get_cookies(user_id): #
try: #
with open("/srv/apps/cybertron/user_session.txt", 'r') as f: # def get_cookies(user_id):
try: # try:
data = f.readlines() # with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
except: # try:
data = None # data = f.readlines()
# except:
list = [] # data = None
for i in data: #
list.append(i.strip('\n').split(",")) # list = []
# for i in data:
for i in list: # list.append(i.strip('\n').split(","))
#
if user_id == i[0]: # for i in list:
return (i[1]) #
except: # if user_id == i[0]:
# return (i[1])
return None # except:
#
# return None
def logins(): #
try: #
user_id = get_majia() # def logins():
# try:
cookies = get_cookies(user_id) # user_id = get_majia()
#
if cookies is not None: # cookies = get_cookies(user_id)
return {'sessionid': cookies} #
# if cookies is not None:
except: # return {'sessionid': cookies}
#
logging.error("catch exception,logins:%s" % traceback.format_exc()) # except:
#
return None # logging.error("catch exception,logins:%s" % traceback.format_exc())
#
# return None
def Urge(cookies_get, id): #
try: #
post_dict = { # def Urge(cookies_get, id):
'id': id # try:
} # post_dict = {
response = requests.post(url=auto_urge_url, # 'id': id
cookies=cookies_get, # }
data=post_dict) # response = requests.post(url=auto_urge_url,
# cookies=cookies_get,
logging.info("response.text:%s" % response.text) # data=post_dict)
#
except: # logging.info("response.text:%s" % response.text)
#
logging.error("catch exception,logins:%s" % traceback.format_exc()) # except:
#
# logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime): #
try: #
now = datetime.datetime.now() # def time_conv(numtime):
yes_time = now - datetime.timedelta(days=numtime) # try:
yes_time_str = yes_time.strftime('%Y-%m-%d') # now = datetime.datetime.now()
return yes_time_str # yes_time = now - datetime.timedelta(days=numtime)
except: # yes_time_str = yes_time.strftime('%Y-%m-%d')
return None # return yes_time_str
# except:
# return None
def get_data(numtime): def get_data(numtime):
try: try:
db = pymysql.connect(host="172.17.40.144", user='work', pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
passwd='oars152!traipseize738', cursor = pc.cursor()
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute( cursor.execute(
"select 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) and user_id in (select user_id from user_extra where is_shadow = 0)", "select 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) and user_id in (select user_id from user_extra where is_shadow = 0)",
(numtime)) (numtime))
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() pc.close()
return user_id 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())
...@@ -125,7 +125,7 @@ if __name__ == "__main__": ...@@ -125,7 +125,7 @@ if __name__ == "__main__":
time.sleep(random.randint(1, 15)) time.sleep(random.randint(1, 15))
cook = logins() cook = login()
if cook is not None: if cook is not None:
Urge(cook, i) Urge(cook, i)
......
...@@ -2,7 +2,7 @@ import requests ...@@ -2,7 +2,7 @@ import requests
import traceback import traceback
import logging import logging
login_url = "http://earth.iyanzhi.com/api/account/login_pwd" login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first(): def index_first():
......
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