Commit 77f4e958 authored by lixiaofang's avatar lixiaofang

add

parent a78a48b1
This diff is collapsed.
......@@ -7,149 +7,152 @@ import pandas as pd
import traceback
from log_settings import *
import logging
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"
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():
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(minutes=15)
print(yes_time)
return yes_time
except:
return None
from auto_request import login, reply, click, get_comment, time_conv
from auto_request import host, user, port, db, passwd
# 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"
# 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():
# try:
# now = datetime.datetime.now()
# yes_time = now - datetime.timedelta(minutes=15)
# print(yes_time)
# 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):
try:
db = pymysql.connect(host="172.17.40.144", user='work', passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.cursor()
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)",
(numtime))
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
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__":
try:
numtime = time_conv()
numtime = time_conv(15)
topic_id = get_topic_id(numtime)
click_num = random.randint(1, 3)
for i in range(click_num):
......
......@@ -6,106 +6,103 @@ import random
import traceback
from log_settings import *
import logging
auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
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 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
from auto_request import login, click, time_convs
from auto_request import host,user,port,db,passwd
# 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 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):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.cursor()
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)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
......@@ -120,7 +117,7 @@ if __name__ == "__main__":
for i in time_list:
numtime = time_conv(i)
numtime = time_convs(i)
user_id = get_data(numtime)
......
......@@ -5,107 +5,106 @@ import pymysql
import random
import traceback
import logging
auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
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 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 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
from auto_request import login, click, time_convs
from auto_request import host,user,port,db,passwd
# 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 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 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):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.cursor()
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)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
......@@ -120,7 +119,7 @@ if __name__ == "__main__":
for i in time_list:
numtime = time_conv(7 + 3 * i)
numtime = time_convs(7 + 3 * i)
user_id = get_data(numtime)
......@@ -149,7 +148,7 @@ if __name__ == "__main__":
time.sleep(random.randint(1, 10))
cook = logins()
cook = login()
if cook is not None:
click(cook, rand_id)
......
......@@ -5,122 +5,123 @@ import pymysql
import random
import traceback
import logging
auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
def get_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen.txt")
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 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,reply:%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
from auto_request import login, time_convs, reply, get_comment
from auto_request import host, user, port, db, passwd
# auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
# def get_majia():
# try:
# data = open("/srv/apps/cybertron/batch_user_gen.txt")
#
# 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 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,reply:%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_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):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.cursor()
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)
data = cursor.fetchall()
topic_id = list(data)
logging.info("Database version : %s " % topic_id)
db.close()
pc.close()
return topic_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
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__":
try:
......@@ -129,7 +130,7 @@ if __name__ == "__main__":
for i in time_list:
numtime = time_conv(i)
numtime = time_convs(i)
topic_id = get_topic_id(numtime)
......@@ -145,7 +146,6 @@ if __name__ == "__main__":
else:
dicts[i[0]].append(i[1])
print(dicts)
for key, value in dicts.items():
......@@ -155,7 +155,7 @@ if __name__ == "__main__":
time.sleep(random.randint(1, 10))
cook = logins()
cook = login()
if cook is not None:
comment = get_comment()
......
......@@ -6,102 +6,103 @@ import random
import traceback
from log_settings import *
import logging
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
auto_pick_url = "http://earth.iyanzhi.com/api/v1/pick/do_pick"
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
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"
#
# auto_pick_url = "http://earth.iyanzhi.com/api/v1/pick/do_pick"
#
#
# 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_topic_new_user(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.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)
topic_data = cursor.fetchall()
......@@ -117,7 +118,7 @@ def get_topic_new_user(numtime):
for i in new_user_data:
user_id.append(i)
logging.info("Database version : %s " % user_id)
db.close()
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
......@@ -127,7 +128,7 @@ def get_topic_new_user(numtime):
if __name__ == "__main__":
try:
numtime = time_conv(0)
numtime = time_convs(0)
user_id = get_topic_new_user(numtime)
......@@ -141,7 +142,7 @@ if __name__ == "__main__":
time.sleep(random.randint(10, 30))
cookies = logins()
cookies = login()
if cookies is not None:
follow(cookies, id)
......
......@@ -6,124 +6,131 @@ import random
import traceback
from log_settings import *
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):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
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)
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.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)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
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)):
if time_list[i] != 11:
numtime = time_conv(time_list[i])
numtime = time_convs(time_list[i])
user_id = get_data(numtime)
follow_num = random.randint(1,2)
follow_num = random.randint(1, 2)
for i in range(follow_num):
......@@ -131,16 +138,15 @@ if __name__ == "__main__":
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:
follow(cookies, id)
time.sleep(300)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -7,86 +7,86 @@ import pandas as pd
import traceback
from log_settings import *
import logging
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"
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(user_id):
try:
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():
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(minutes=15)
return yes_time
except:
return None
from auto_request import login, time_conv, follow
from auto_request import host, user, port, db, passwd
# 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"
#
#
# 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(user_id):
# try:
# 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():
# try:
# now = datetime.datetime.now()
# yes_time = now - datetime.timedelta(minutes=15)
# return yes_time
# except:
# return None
def get_follw_majia(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.cursor()
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%%%%' " % (
numtime))
data = cursor.fetchall()
data = list(data)
logging.info("Database version : %s " % data)
db.close()
pc.close()
return data
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
......@@ -99,8 +99,6 @@ if __name__ == "__main__":
numtime = time_conv()
# get majia zhanghao
data = get_follw_majia(numtime)
dict_follow_id = {}
......@@ -139,7 +137,7 @@ if __name__ == "__main__":
for i in value:
cookies = logins(id)
cookies = login(id)
if cookies is not None:
follow(cookies, i)
......
......@@ -6,99 +6,101 @@ import random
import traceback
from log_settings import *
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):
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.cursor()
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)
......@@ -155,7 +157,7 @@ def get_commnet_id(numtime):
logging.info("Database version : %s " % user_id)
db.close()
pc.close()
return user_id
......@@ -164,7 +166,7 @@ if __name__ == "__main__":
try:
numtime = time_conv(1)
numtime = time_convs(1)
user_id = get_commnet_id(numtime)
......@@ -178,7 +180,7 @@ if __name__ == "__main__":
time.sleep(random.randint(10, 50))
cookies = logins()
cookies = login()
if cookies is not None:
follow(cookies, id)
......
......@@ -6,102 +6,106 @@ import random
import traceback
from log_settings import *
import logging
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
from auto_request import login, time_conv, follow,get_cookies
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_data(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',passwd='oars152!traipseize738',db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
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))
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
......@@ -123,7 +127,7 @@ if __name__ == "__main__":
time.sleep(random.randint(1, 10))
cook=logins()
cook=login()
if cook is not None:
......
......@@ -6,106 +6,106 @@ import random
import traceback
from log_settings import *
import logging
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
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_data(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.cursor()
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)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
logging.pcinfo("Database version : %s " % user_id)
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
......@@ -114,7 +114,7 @@ def get_data(numtime):
if __name__ == "__main__":
try:
numtime = time_conv(1)
numtime = time_convs(1)
user_id = get_data(numtime)
urge_num = random.randint(0, 1)
......@@ -125,10 +125,12 @@ if __name__ == "__main__":
time.sleep(random.randint(1, 10))
cook = logins()
cook = login()
if cook is not None:
follow(cook, id)
time.sleep(300)
except:
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
import traceback
from log_settings import *
import logging
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
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 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 follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
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
from auto_request import login, time_conv, follow,click
from auto_request import host, user, port, db, passwd
# auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
#
# auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
#
#
# 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 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 follow(cookies_get, id):
# try:
# post_dict = {
# 'type': 1,
# 'id': id
# }
# response = requests.post(url=auto_follow_url,
# cookies=cookies_get,
# data=post_dict)
#
# print(response.text, 'url')
#
# 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_star_user_id(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.cursor()
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)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
......@@ -135,16 +135,14 @@ def get_star_user_id(numtime):
def get_star_topic_id(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.cursor()
cursor.execute(
"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()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
......@@ -171,9 +169,10 @@ if __name__ == "__main__":
time.sleep(random.randint(1, 10))
cookies = logins()
cookies = login()
if cookies is not None:
click(cookies, id)
time.sleep(300)
......@@ -189,7 +188,7 @@ if __name__ == "__main__":
time.sleep(random.randint(1, 10))
cookies = logins()
cookies = login()
if cookies is not None:
follow(cookies, id)
......
......@@ -7,108 +7,110 @@ import pandas as pd
import traceback
from log_settings import *
import logging
auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
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 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())
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
from auto_request import login, time_conv, Urge
from auto_request import host, user, port, db, passwd
# auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
# 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 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())
#
# 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_star_useid(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.cursor()
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)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
pc.close()
return user_id
except:
......@@ -135,7 +137,7 @@ if __name__ == "__main__":
time.sleep(random.randint(10, 50))
cookies = logins()
cookies = login()
if cookies is not None:
......
......@@ -7,107 +7,107 @@ import pandas as pd
import traceback
from log_settings import *
import logging
auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
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 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())
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
from auto_request import login, time_conv, Urge
from auto_request import host, user, port, db, passwd
# auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
#
# 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 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())
#
# 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):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.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)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
......@@ -135,7 +135,7 @@ if __name__ == "__main__":
time.sleep(random.randint(3, 10))
cookies=logins()
cookies=login()
if cookies is not None:
......
......@@ -7,105 +7,105 @@ import traceback
from log_settings import *
import logging
auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
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 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())
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
from auto_request import login, time_conv, Urge
from auto_request import host, user, port, db, passwd
# auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
#
# 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 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())
#
#
# 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):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
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))
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
......@@ -125,7 +125,7 @@ if __name__ == "__main__":
time.sleep(random.randint(1, 15))
cook = logins()
cook = login()
if cook is not None:
Urge(cook, i)
......
......@@ -2,7 +2,7 @@ import requests
import traceback
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():
......
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