Commit 4dfd22a1 authored by lixiaofang's avatar lixiaofang

try except

parent 02f87232
This diff is collapsed.
...@@ -4,24 +4,32 @@ import datetime ...@@ -4,24 +4,32 @@ import datetime
import pymysql import pymysql
import random import random
import pandas as pd import pandas as pd
import traceback
from log_settings import *
import logging
auto_click_url = "http://earth.igengmei.com/api/v1/like" auto_click_url = "http://earth.igengmei.com/api/v1/like"
auto_reply_url = "http://earth.igengmei.com/api/v1/reply/create" auto_reply_url = "http://earth.igengmei.com/api/v1/reply/create"
auto_follow_url = "http://earth.igengmei.com/api/v1/follow" auto_follow_url = "http://earth.igengmei.com/api/v1/follow"
login_url = "http://earth.igengmei.com/api/account/login_pwd" login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first(): def index_first():
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
r1=requests.get(login_url) logging.error("index_first:%s" % traceback.format_exc())
return r1.cookies.get_dict() return None
def get_majia(): def get_majia():
try:
data = open("batch user gen") data = open("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(','))
...@@ -33,8 +41,14 @@ def get_majia(): ...@@ -33,8 +41,14 @@ def get_majia():
return user_id return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def login(): def login():
try:
# time.sleep(random.randint(300, 500)) # time.sleep(random.randint(300, 500))
user_id=get_majia() user_id=get_majia()
...@@ -58,14 +72,19 @@ def login(): ...@@ -58,14 +72,19 @@ def login():
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
print(response.text, 'url') logging.info("response.text :%s"%response.text)
print(cook)
return {'sessionid': cook} return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def logins(id): def logins(id):
try:
cookies = index_first() cookies = index_first()
post_dict={ post_dict={
...@@ -85,11 +104,19 @@ def logins(id): ...@@ -85,11 +104,19 @@ def logins(id):
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
print(response.text, 'url') logging.info("response.text :%s" % response.text)
return {'sessionid': cook} return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id): def follow(cookies_get, id):
try:
post_dict = { post_dict = {
'type': 1, 'type': 1,
'id': id 'id': id
...@@ -98,9 +125,15 @@ def follow(cookies_get, id): ...@@ -98,9 +125,15 @@ def follow(cookies_get, id):
cookies=cookies_get, cookies=cookies_get,
data=post_dict) 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 click(cookies_get, id): def click(cookies_get, id):
try:
post_dict = { post_dict = {
'type': 1, 'type': 1,
'id': id 'id': id
...@@ -109,9 +142,15 @@ def click(cookies_get, id): ...@@ -109,9 +142,15 @@ def click(cookies_get, id):
cookies=cookies_get, cookies=cookies_get,
data=post_dict) 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 reply(cookies_get,id,content): def reply(cookies_get,id,content):
try:
post_dict={ post_dict={
'topic_id':id, 'topic_id':id,
'content':content 'content':content
...@@ -120,33 +159,39 @@ def reply(cookies_get,id,content): ...@@ -120,33 +159,39 @@ def reply(cookies_get,id,content):
cookies=cookies_get, cookies=cookies_get,
data=post_dict) data=post_dict)
print(response.text, 'url') logging.info("response.text:%s" % response.text)
def time_conv(): except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv():
try:
now = datetime.datetime.now() now = datetime.datetime.now()
yes_time = now - datetime.timedelta(minutes=15) yes_time = now - datetime.timedelta(minutes=15)
print(yes_time) print(yes_time)
return yes_time return yes_time
def get_topic_id(numtime): except:
return None
def get_topic_id(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
print("---------")
cursor.execute("SELECT id FROM topic WHERE create_time >= %s" ,(numtime)) cursor.execute("SELECT id FROM topic WHERE create_time >= %s" ,(numtime))
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id)
print("Database version : %s " % user_id)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
def get_comment(): def get_comment():
try:
data = pd.read_csv("guanshui", sep='\n') data = pd.read_csv("guanshui", sep='\n')
num = random.randint(0, len(data)) num = random.randint(0, len(data))
list_guanshui = [] list_guanshui = []
...@@ -158,7 +203,12 @@ def get_comment(): ...@@ -158,7 +203,12 @@ def get_comment():
return comment return comment
except:
return None
if __name__ == "__main__": if __name__ == "__main__":
try:
numtime=time_conv() numtime=time_conv()
...@@ -196,4 +246,5 @@ if __name__ == "__main__": ...@@ -196,4 +246,5 @@ if __name__ == "__main__":
comment = get_comment() comment = get_comment()
reply(cookies, id, comment) reply(cookies, id, comment)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -3,7 +3,9 @@ import time ...@@ -3,7 +3,9 @@ import time
import datetime import datetime
import pymysql import pymysql
import random import random
import traceback
from log_settings import *
import logging
# s = requests.session() # s = requests.session()
# #
# s.keep_alive = False # s.keep_alive = False
...@@ -15,16 +17,22 @@ auto_click_url = "http://earth.igengmei.com/api/v1/like" ...@@ -15,16 +17,22 @@ auto_click_url = "http://earth.igengmei.com/api/v1/like"
login_url = "http://earth.igengmei.com/api/account/login_pwd" login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first(): def index_first():
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
r1=requests.get(login_url) logging.error("index_first:%s" % traceback.format_exc())
return r1.cookies.get_dict() return None
def get_majia(): def get_majia():
try:
data = open("batch user gen") data = open("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(','))
...@@ -34,12 +42,15 @@ def get_majia(): ...@@ -34,12 +42,15 @@ def get_majia():
user_id=list[maj-1] user_id=list[maj-1]
print(user_id)
return user_id return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def login(): def login():
try:
# time.sleep(random.randint(300, 500)) # time.sleep(random.randint(300, 500))
user_id=get_majia() user_id=get_majia()
...@@ -63,14 +74,18 @@ def login(): ...@@ -63,14 +74,18 @@ def login():
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
print(response.text, 'url') logging.info("response.text %s"%response.text)
print(cook)
return {'sessionid': cook} return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def click(cookies_get, id): def click(cookies_get, id):
try:
post_dict = { post_dict = {
'type': 1, 'type': 1,
'id': id 'id': id
...@@ -79,29 +94,40 @@ def click(cookies_get, id): ...@@ -79,29 +94,40 @@ def click(cookies_get, id):
cookies=cookies_get, cookies=cookies_get,
data=post_dict) data=post_dict)
print(response.text, 'url') logging.info("response.text:%s" % response.text)
def time_conv(numtime): except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
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:
return None
def get_data(numtime): def get_data(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
print("---------")
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
print("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__": if __name__ == "__main__":
try:
time_list = [1,2,3,4,5,6,7] time_list = [1,2,3,4,5,6,7]
for i in time_list: for i in time_list:
...@@ -137,7 +163,8 @@ if __name__ == "__main__": ...@@ -137,7 +163,8 @@ if __name__ == "__main__":
click(cook, rand_id) click(cook, rand_id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
...@@ -3,22 +3,30 @@ import time ...@@ -3,22 +3,30 @@ import time
import datetime import datetime
import pymysql import pymysql
import random import random
import traceback
from log_settings import *
import logging
auto_click_url = "http://earth.igengmei.com/api/v1/like" auto_click_url = "http://earth.igengmei.com/api/v1/like"
login_url = "http://earth.igengmei.com/api/account/login_pwd" login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first(): def index_first():
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
r1=requests.get(login_url) logging.error("index_first:%s" % traceback.format_exc())
return r1.cookies.get_dict() return None
def get_majia(): def get_majia():
try:
data = open("batch user gen") data = open("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(','))
...@@ -28,12 +36,16 @@ def get_majia(): ...@@ -28,12 +36,16 @@ def get_majia():
user_id=list[maj-1] user_id=list[maj-1]
print(user_id)
return user_id return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins(): def logins():
try:
# time.sleep(random.randint(300, 500)) # time.sleep(random.randint(300, 500))
user_id=get_majia() user_id=get_majia()
...@@ -57,14 +69,18 @@ def logins(): ...@@ -57,14 +69,18 @@ def logins():
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
print(response.text, 'url') logging.info("response.text : %s"%response.text)
print(cook)
return {'sessionid': cook} return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def click(cookies_get, id): def click(cookies_get, id):
try:
post_dict = { post_dict = {
'type': 1, 'type': 1,
'id': id 'id': id
...@@ -73,16 +89,23 @@ def click(cookies_get, id): ...@@ -73,16 +89,23 @@ def click(cookies_get, id):
cookies=cookies_get, cookies=cookies_get,
data=post_dict) data=post_dict)
print(response.text, 'url') logging.info("response.text:%s" % response.text)
def time_conv(numtime): except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
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:
return None
def get_data(numtime): def get_data(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
...@@ -90,12 +113,18 @@ def get_data(numtime): ...@@ -90,12 +113,18 @@ def get_data(numtime):
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
print("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__": if __name__ == "__main__":
try:
time_list = [1,2,3,4,5,6,7] time_list = [1,2,3,4,5,6,7]
for i in time_list: for i in time_list:
...@@ -131,3 +160,5 @@ if __name__ == "__main__": ...@@ -131,3 +160,5 @@ if __name__ == "__main__":
click(cook, rand_id) click(cook, rand_id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
\ No newline at end of file
...@@ -3,28 +3,32 @@ import time ...@@ -3,28 +3,32 @@ import time
import datetime import datetime
import pymysql import pymysql
import random import random
import traceback
# s = requests.session() from log_settings import *
# import logging
# s.keep_alive = False
#
# requests.adapters.DEFAULT_RETRIES = 5
auto_follow_url = "http://earth.igengmei.com/api/v1/follow" auto_follow_url = "http://earth.igengmei.com/api/v1/follow"
login_url = "http://earth.igengmei.com/api/account/login_pwd" login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first(): def index_first():
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
r1=requests.get(login_url) logging.error("index_first:%s" % traceback.format_exc())
return None
return r1.cookies.get_dict()
def get_majia(): def get_majia():
try:
data = open("batch user gen") data = open("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(','))
...@@ -34,12 +38,16 @@ def get_majia(): ...@@ -34,12 +38,16 @@ def get_majia():
user_id=list[maj-1] user_id=list[maj-1]
print(user_id)
return user_id return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins(): def logins():
try:
# time.sleep(random.randint(300, 500)) # time.sleep(random.randint(300, 500))
user_id=get_majia() user_id=get_majia()
...@@ -63,43 +71,57 @@ def logins(): ...@@ -63,43 +71,57 @@ def logins():
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
print(response.text, 'url') logging.info("response.text %s"%response.text)
print(cook)
return {'sessionid': cook} return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id): def follow(cookies_get, id):
try:
post_dict = { post_dict = {
'type': 1, 'type': 1,
'id': id 'id': id
} }
response = requests.post(url=auto_follow_url, response = requests.post(url=auto_click_url,
cookies=cookies_get, cookies=cookies_get,
data=post_dict) data=post_dict)
print(response.text, 'url') logging.info("response.text:%s" % response.text)
def time_conv(numtime): except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
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:
return None
def get_data(numtime): def get_data(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
print("---------")
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
print("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__": if __name__ == "__main__":
try:
#time.sleep(random.randint(3000,4500)) #time.sleep(random.randint(3000,4500))
...@@ -119,6 +141,9 @@ if __name__ == "__main__": ...@@ -119,6 +141,9 @@ if __name__ == "__main__":
follow(cook, id) follow(cook, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
...@@ -76,10 +76,6 @@ def logins(): ...@@ -76,10 +76,6 @@ def logins():
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
print(response.text, 'url')
print(cook)
return {'sessionid': cook} return {'sessionid': cook}
except: except:
...@@ -98,7 +94,6 @@ def reply(cookies_get,id,content): ...@@ -98,7 +94,6 @@ def reply(cookies_get,id,content):
cookies=cookies_get, cookies=cookies_get,
data=post_dict) data=post_dict)
print(response.text,'url')
logging.info("response.text :%s"%(response.text)) logging.info("response.text :%s"%(response.text))
except: except:
...@@ -115,11 +110,9 @@ def time_conv(numtime): ...@@ -115,11 +110,9 @@ def time_conv(numtime):
return None return None
def get_topic_id(numtime): def get_topic_id(numtime):
try: try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db="alpha", port=3306) db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
# print("---------")
cursor.execute("SELECT id FROM topic WHERE create_time LIKE '%%%%%s%%%%' " %numtime) cursor.execute("SELECT id FROM topic WHERE create_time LIKE '%%%%%s%%%%' " %numtime)
data = cursor.fetchall() data = cursor.fetchall()
topic_id = list(data) topic_id = list(data)
...@@ -127,6 +120,7 @@ def get_topic_id(numtime): ...@@ -127,6 +120,7 @@ def get_topic_id(numtime):
db.close() db.close()
return topic_id return topic_id
except: except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return None
def get_comment(): def get_comment():
......
...@@ -3,7 +3,9 @@ import time ...@@ -3,7 +3,9 @@ import time
import datetime import datetime
import pymysql import pymysql
import random import random
import traceback
from log_settings import *
import logging
auto_follow_url = "http://earth.igengmei.com/api/v1/follow" auto_follow_url = "http://earth.igengmei.com/api/v1/follow"
login_url = "http://earth.igengmei.com/api/account/login_pwd" login_url = "http://earth.igengmei.com/api/account/login_pwd"
...@@ -11,14 +13,23 @@ login_url = "http://earth.igengmei.com/api/account/login_pwd" ...@@ -11,14 +13,23 @@ login_url = "http://earth.igengmei.com/api/account/login_pwd"
auto_pick_url = "http://earth.igengmei.com/api/v1/pick/do_pick" auto_pick_url = "http://earth.igengmei.com/api/v1/pick/do_pick"
def index_first(): def index_first():
r1=requests.get(login_url) try:
r1 = requests.get(login_url)
return r1.cookies.get_dict() return r1.cookies.get_dict()
except:
logging.error("index_first:%s" % traceback.format_exc())
return None
def get_majia(): def get_majia():
try:
data = open("batch user gen") data = open("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(','))
...@@ -28,12 +39,16 @@ def get_majia(): ...@@ -28,12 +39,16 @@ def get_majia():
user_id=list[maj-1] user_id=list[maj-1]
print(user_id)
return user_id return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins(): def logins():
try:
# time.sleep(random.randint(300, 500)) # time.sleep(random.randint(300, 500))
user_id=get_majia() user_id=get_majia()
...@@ -57,13 +72,19 @@ def logins(): ...@@ -57,13 +72,19 @@ def logins():
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
print(response.text, 'url') logging.info("response.text :%s" %response.text)
print(cook)
return {'sessionid': cook} return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id): def follow(cookies_get, id):
try:
post_dict = { post_dict = {
'type': 1, 'type': 1,
'id': id 'id': id
...@@ -72,70 +93,84 @@ def follow(cookies_get, id): ...@@ -72,70 +93,84 @@ def follow(cookies_get, id):
cookies=cookies_get, cookies=cookies_get,
data=post_dict) 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 pick(cookies_get,id): def pick(cookies_get,id):
post_dict={
'pick_user_id':id, try:
'is_pick':1, post_dict = {
'pick_type':0 'pick_user_id': id,
'is_pick': 1,
'pick_type': 0
} }
response=requests.post(url=auto_pick_url, response = requests.post(url=auto_pick_url,
cookies=cookies_get, cookies=cookies_get,
data=post_dict) data=post_dict)
print(response.headers) logging.info("response.text:%s" % response.text)
print(response.text, 'url') except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime): def time_conv(numtime):
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')
print(now)
return yes_time_str return yes_time_str
except:
return None
def get_topic_new_user(numtime): def get_topic_new_user(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
print("---------")
cursor.execute("SELECT user_id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute("SELECT user_id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
topic_data = cursor.fetchall() topic_data = cursor.fetchall()
cursor.execute("SELECT user_id FROM group_user_role WHERE create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute("SELECT user_id FROM group_user_role WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
new_user_data = cursor.fetchall() new_user_data = cursor.fetchall()
topic_data = list(topic_data) topic_data = list(topic_data)
new_user_data = list(new_user_data) new_user_data = list(new_user_data)
user_id = [] user_id = []
for i in topic_data: for i in topic_data:
user_id.append(i) user_id.append(i)
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)
print("Database version : %s " % user_id)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
def get_topic_data(numtime): def get_topic_data(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
print("---------")
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
print("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close()
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__": if __name__ == "__main__":
try:
numtime = time_conv(0) numtime = time_conv(0)
...@@ -171,6 +206,8 @@ if __name__ == "__main__": ...@@ -171,6 +206,8 @@ if __name__ == "__main__":
cookies = logins() cookies = logins()
pick(cookies, id) pick(cookies, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
...@@ -3,20 +3,30 @@ import time ...@@ -3,20 +3,30 @@ import time
import datetime import datetime
import pymysql import pymysql
import random import random
import traceback
from log_settings import *
import logging
auto_follow_url = "http://earth.igengmei.com/api/v1/follow" auto_follow_url = "http://earth.igengmei.com/api/v1/follow"
login_url = "http://earth.igengmei.com/api/account/login_pwd" login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first(): def index_first():
r1=requests.get(login_url) try:
r1 = requests.get(login_url)
return r1.cookies.get_dict() return r1.cookies.get_dict()
except:
logging.error("index_first:%s" % traceback.format_exc())
return None
def get_majia(): def get_majia():
try:
data = open("batch user gen") data = open("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(','))
...@@ -26,12 +36,16 @@ def get_majia(): ...@@ -26,12 +36,16 @@ def get_majia():
user_id=list[maj-1] user_id=list[maj-1]
print(user_id)
return user_id return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins(): def logins():
try:
# time.sleep(random.randint(300, 500)) # time.sleep(random.randint(300, 500))
user_id=get_majia() user_id=get_majia()
...@@ -55,13 +69,19 @@ def logins(): ...@@ -55,13 +69,19 @@ def logins():
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
print(response.text, 'url') logging.info("response.text :%s"%response.text)
print(cook)
return {'sessionid': cook} return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id): def follow(cookies_get, id):
try:
post_dict = { post_dict = {
'type': 1, 'type': 1,
'id': id 'id': id
...@@ -70,30 +90,35 @@ def follow(cookies_get, id): ...@@ -70,30 +90,35 @@ def follow(cookies_get, id):
cookies=cookies_get, cookies=cookies_get,
data=post_dict) 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): def time_conv(numtime):
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')
print(now)
return yes_time_str return yes_time_str
except:
return None
def get_data(numtime): def get_data(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
print("---------")
cursor.execute("SELECT distinct(user_id) FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute("SELECT distinct(user_id) FROM topic WHERE 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)
print("Database version : %s " % user_id)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
def get_commnet_id(numtime): def get_commnet_id(numtime):
...@@ -146,6 +171,8 @@ def get_commnet_id(numtime): ...@@ -146,6 +171,8 @@ def get_commnet_id(numtime):
if __name__ == "__main__": 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 time_list: for i in time_list:
...@@ -194,6 +221,7 @@ if __name__ == "__main__": ...@@ -194,6 +221,7 @@ if __name__ == "__main__":
# time.sleep(random.randint(2000, 3000)) # time.sleep(random.randint(2000, 3000))
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -4,7 +4,9 @@ import datetime ...@@ -4,7 +4,9 @@ import datetime
import pymysql import pymysql
import random import random
import pandas as pd import pandas as pd
import traceback
from log_settings import *
import logging
auto_click_url = "http://earth.igengmei.com/api/v1/like" auto_click_url = "http://earth.igengmei.com/api/v1/like"
auto_reply_url = "http://earth.igengmei.com/api/v1/reply/create" auto_reply_url = "http://earth.igengmei.com/api/v1/reply/create"
auto_follow_url = "http://earth.igengmei.com/api/v1/follow" auto_follow_url = "http://earth.igengmei.com/api/v1/follow"
...@@ -12,19 +14,48 @@ login_url = "http://earth.igengmei.com/api/account/login_pwd" ...@@ -12,19 +14,48 @@ login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first(): def index_first():
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
r1=requests.get(login_url) logging.error("index_first:%s" % traceback.format_exc())
return r1.cookies.get_dict() return None
def get_majia():
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
# time.sleep(random.randint(0, 500))
maj = random.randint(1,len(list))
def logins(id): user_id=list[maj-1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins(user_id):
try:
# time.sleep(random.randint(300, 500))
cookies = index_first() cookies = index_first()
post_dict={ post_dict = {
'account_type':2, 'account_type': 2,
'pwd':'123456', 'pwd': '123456',
'email':id 'email': user_id
} }
response = requests.post( response = requests.post(
url=login_url, url=login_url,
...@@ -32,17 +63,26 @@ def logins(id): ...@@ -32,17 +63,26 @@ def logins(id):
cookies=cookies cookies=cookies
) )
headers=response.headers headers = response.headers
cook = headers['Set-Cookie'].split(";") cook = headers['Set-Cookie'].split(";")
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
print(response.text, 'url') logging.info("response.text :%s" % response.text)
return {'sessionid': cook} return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id): def follow(cookies_get, id):
try:
post_dict = { post_dict = {
'type': 1, 'type': 1,
'id': id 'id': id
...@@ -51,37 +91,42 @@ def follow(cookies_get, id): ...@@ -51,37 +91,42 @@ def follow(cookies_get, id):
cookies=cookies_get, cookies=cookies_get,
data=post_dict) 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():
def time_conv():
try:
now = datetime.datetime.now() now = datetime.datetime.now()
yes_time = now - datetime.timedelta(minutes=15) yes_time = now - datetime.timedelta(minutes=15)
return yes_time return yes_time
except:
def get_follw_majia(numtime,id): return None
def get_follw_majia(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
print("---------")
cursor.execute("select temp1.user_id,temp1.email,temp2.follow_id from account_user_auth temp1 left join " cursor.execute("select temp1.user_id,temp1.email,temp2.follow_id from account_user_auth temp1 left join "
"(select user_id,follow_id from user_follow) " "(select user_id,follow_id from user_follow) "
" temp2 on temp1.user_id=temp2.user_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','s_1iyrBU@shadow.com')") " temp2 on temp1.user_id=temp2.user_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','s_1iyrBU@shadow.com') and create_time >= '%s' "%numtime)
data = cursor.fetchall() data = cursor.fetchall()
data=list(data) data=list(data)
logging.info("Database version : %s " % data)
print("Database version : %s " % data)
db.close() db.close()
return data return data
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__": if __name__ == "__main__":
try:
numtime=time_conv() numtime=time_conv()
# get majia zhanghao # get majia zhanghao
...@@ -124,11 +169,12 @@ if __name__ == "__main__": ...@@ -124,11 +169,12 @@ if __name__ == "__main__":
for i in value: for i in value:
cookies=logins() cookies=logins(id)
follow(cookies,i) follow(cookies,i)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
...@@ -3,13 +3,9 @@ import time ...@@ -3,13 +3,9 @@ import time
import datetime import datetime
import pymysql import pymysql
import random import random
import traceback
# s = requests.session() from log_settings import *
# import logging
# s.keep_alive = False
#
# requests.adapters.DEFAULT_RETRIES = 5
auto_click_url = "http://earth.igengmei.com/api/v1/like" auto_click_url = "http://earth.igengmei.com/api/v1/like"
login_url = "http://earth.igengmei.com/api/account/login_pwd" login_url = "http://earth.igengmei.com/api/account/login_pwd"
...@@ -19,16 +15,22 @@ auto_pick_url = "http://earth.igengmei.com/api/v1/pick/do_pick" ...@@ -19,16 +15,22 @@ auto_pick_url = "http://earth.igengmei.com/api/v1/pick/do_pick"
auto_follow_url = "http://earth.igengmei.com/api/v1/follow" auto_follow_url = "http://earth.igengmei.com/api/v1/follow"
def index_first(): def index_first():
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
r1=requests.get(login_url) logging.error("index_first:%s" % traceback.format_exc())
return r1.cookies.get_dict() return None
def get_majia(): def get_majia():
try:
data = open("batch user gen") data = open("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(','))
...@@ -38,12 +40,16 @@ def get_majia(): ...@@ -38,12 +40,16 @@ def get_majia():
user_id=list[maj-1] user_id=list[maj-1]
print(user_id)
return user_id return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins(): def logins():
try:
# time.sleep(random.randint(300, 500)) # time.sleep(random.randint(300, 500))
user_id=get_majia() user_id=get_majia()
...@@ -67,13 +73,18 @@ def logins(): ...@@ -67,13 +73,18 @@ def logins():
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
print(response.text, 'url') logging.info("response.text :%s" % response.text)
print(cook)
return {'sessionid': cook} return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id): def follow(cookies_get, id):
try:
post_dict = { post_dict = {
'type': 1, 'type': 1,
'id': id 'id': id
...@@ -82,42 +93,56 @@ def follow(cookies_get, id): ...@@ -82,42 +93,56 @@ def follow(cookies_get, id):
cookies=cookies_get, cookies=cookies_get,
data=post_dict) 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 pick(cookies_get,id): def pick(cookies_get,id):
post_dict={
'pick_user_id':id, try:
'is_pick':1, post_dict = {
'pick_type':0 'pick_user_id': id,
'is_pick': 1,
'pick_type': 0
} }
response=requests.post(url=auto_pick_url, response = requests.post(url=auto_pick_url,
cookies=cookies_get, cookies=cookies_get,
data=post_dict) data=post_dict)
print(response.headers) logging.info("response.text:%s" % response.text)
print(response.text, 'url') except:
def time_conv(numtime): logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
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:
return None
def get_data(numtime): def get_data(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
print("---------")
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
print("Database version : %s " % user_id) logging.info("Database version : %s " % data)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__": if __name__ == "__main__":
try:
#time.sleep(random.randint(3000,4500)) #time.sleep(random.randint(3000,4500))
...@@ -140,9 +165,8 @@ if __name__ == "__main__": ...@@ -140,9 +165,8 @@ if __name__ == "__main__":
pick(cook, id) pick(cook, id)
follow(cook,id) follow(cook,id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
...@@ -3,22 +3,30 @@ import time ...@@ -3,22 +3,30 @@ import time
import datetime import datetime
import pymysql import pymysql
import random import random
import traceback
from log_settings import *
import logging
auto_pick_url = "http://earth.igengmei.com/api/v1/pick/do_pick" auto_pick_url = "http://earth.igengmei.com/api/v1/pick/do_pick"
login_url = "http://earth.igengmei.com/api/account/login_pwd" login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first(): def index_first():
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
r1=requests.get(login_url) logging.error("index_first:%s" % traceback.format_exc())
return r1.cookies.get_dict() return None
def get_majia(): def get_majia():
try:
data = open("batch user gen") data = open("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(','))
...@@ -28,12 +36,16 @@ def get_majia(): ...@@ -28,12 +36,16 @@ def get_majia():
user_id=list[maj-1] user_id=list[maj-1]
print(user_id)
return user_id return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def login(): def login():
try:
# time.sleep(random.randint(300, 500)) # time.sleep(random.randint(300, 500))
user_id=get_majia() user_id=get_majia()
...@@ -57,14 +69,20 @@ def login(): ...@@ -57,14 +69,20 @@ def login():
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
print(response.text, 'url') logging.info("response.text :%s" % response.text)
print(cook)
return {'sessionid': cook} return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def logins(id): def logins(id):
try:
cookies = index_first() cookies = index_first()
post_dict={ post_dict={
...@@ -84,95 +102,94 @@ def logins(id): ...@@ -84,95 +102,94 @@ def logins(id):
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
print(response.text, 'url') logging.info("response.text :%s" % response.text)
return {'sessionid': cook} return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def pick(cookies_get,id): def pick(cookies_get,id):
post_dict={
'pick_user_id':id, try:
'is_pick':1, post_dict = {
'pick_type':0 'pick_user_id': id,
'is_pick': 1,
'pick_type': 0
} }
response=requests.post(url=auto_pick_url, response = requests.post(url=auto_pick_url,
cookies=cookies_get, cookies=cookies_get,
data=post_dict) data=post_dict)
print(response.headers) logging.info("response.text:%s" % response.text)
print(response.text, 'url') except:
def time_conv(numtime): logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
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')
print(now)
return yes_time_str return yes_time_str
except:
return None
def get_data(numtime): def get_data(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db="alpha", port=3306) db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
print("---------")
cursor.execute("SELECT distinct(user_id) FROM topic WHERE create_time LIKE '%%%%%s%%%%'" %numtime) cursor.execute("SELECT distinct(user_id) FROM topic WHERE create_time LIKE '%%%%%s%%%%'" %numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % data)
print("Database version : %s " % user_id)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
def get_new_user_id(numtime): def get_new_user_id(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
print("---------")
cursor.execute( cursor.execute(
"select user_id from account_user WHERE create_time LIKE '%%%%%s%%%%'" % numtime) "select user_id from account_user WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data_new_user = cursor.fetchall() data_new_user = cursor.fetchall()
data = list(data_new_user)
data3_id = list(data_new_user) logging.info("Database version : %s " % data)
print("Database version : %s " % user_id)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
def get_star_useid(numtime): def get_star_useid(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute( cursor.execute(
"SELECT user_id FROM topic WHERE content_level =4 or content_level =5 and create_time LIKE '%%%%%s%%%%'" % numtime) "SELECT user_id FROM topic WHERE 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 " % data)
print("Database version : %s " % user_id)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__": if __name__ == "__main__":
try:
time_list = [1,2,3,4,5,6,7] time_list = [1,2,3,4,5,6,7]
#topic #topic
...@@ -247,4 +264,5 @@ if __name__ == "__main__": ...@@ -247,4 +264,5 @@ if __name__ == "__main__":
pick(cookies, i) pick(cookies, i)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -3,28 +3,31 @@ import time ...@@ -3,28 +3,31 @@ import time
import datetime import datetime
import pymysql import pymysql
import random import random
import traceback
# s = requests.session() from log_settings import *
# import logging
# s.keep_alive = False
#
# requests.adapters.DEFAULT_RETRIES = 5
auto_urge_url = "http://earth.igengmei.com/api/v1/user/urge" auto_urge_url = "http://earth.igengmei.com/api/v1/user/urge"
login_url = "http://earth.igengmei.com/api/account/login_pwd" login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first(): def index_first():
try:
r1 = requests.get(login_url) r1 = requests.get(login_url)
return r1.cookies.get_dict() return r1.cookies.get_dict()
except:
logging.error("index_first:%s" % traceback.format_exc())
return None
def get_majia(): def get_majia():
try:
data = open("batch user gen") data = open("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(','))
...@@ -34,12 +37,16 @@ def get_majia(): ...@@ -34,12 +37,16 @@ def get_majia():
user_id=list[maj-1] user_id=list[maj-1]
print(user_id)
return user_id return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins(): def logins():
try:
# time.sleep(random.randint(300, 500)) # time.sleep(random.randint(300, 500))
user_id=get_majia() user_id=get_majia()
...@@ -63,13 +70,19 @@ def logins(): ...@@ -63,13 +70,19 @@ def logins():
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
print(response.text, 'url') logging.info("response.text :%s" % response.text)
print(cook)
return {'sessionid': cook} return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def Urge(cookies_get, id): def Urge(cookies_get, id):
try:
post_dict = { post_dict = {
'id': id 'id': id
} }
...@@ -77,27 +90,39 @@ def Urge(cookies_get, id): ...@@ -77,27 +90,39 @@ def Urge(cookies_get, id):
cookies=cookies_get, cookies=cookies_get,
data=post_dict) 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): def time_conv(numtime):
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:
return None
def get_data(numtime): def get_data(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
print("---------")
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
print("Database version : %s " % user_id) logging.info("Database version : %s " % data)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__": if __name__ == "__main__":
try:
# time.sleep(random.randint(3000,4500)) # time.sleep(random.randint(3000,4500))
...@@ -116,7 +141,8 @@ if __name__ == "__main__": ...@@ -116,7 +141,8 @@ if __name__ == "__main__":
Urge(cook, id) Urge(cook, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
...@@ -3,12 +3,9 @@ import time ...@@ -3,12 +3,9 @@ import time
import datetime import datetime
import pymysql import pymysql
import random import random
import traceback
# s = requests.session() from log_settings import *
# import logging
# s.keep_alive = False
#
# requests.adapters.DEFAULT_RETRIES = 5
auto_follow_url = "http://earth.igengmei.com/api/v1/follow" auto_follow_url = "http://earth.igengmei.com/api/v1/follow"
...@@ -17,16 +14,22 @@ auto_click_url = "http://earth.igengmei.com/api/v1/like" ...@@ -17,16 +14,22 @@ auto_click_url = "http://earth.igengmei.com/api/v1/like"
login_url = "http://earth.igengmei.com/api/account/login_pwd" login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first(): def index_first():
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
r1=requests.get(login_url) logging.error("index_first:%s" % traceback.format_exc())
return r1.cookies.get_dict() return None
def get_majia(): def get_majia():
try:
data = open("batch user gen") data = open("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(','))
...@@ -36,12 +39,16 @@ def get_majia(): ...@@ -36,12 +39,16 @@ def get_majia():
user_id=list[maj-1] user_id=list[maj-1]
print(user_id)
return user_id return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins(): def logins():
try:
# time.sleep(random.randint(300, 500)) # time.sleep(random.randint(300, 500))
user_id=get_majia() user_id=get_majia()
...@@ -65,14 +72,19 @@ def logins(): ...@@ -65,14 +72,19 @@ def logins():
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
print(response.text, 'url') logging.info("response.text :%s" % response.text)
print(cook)
return {'sessionid': cook} return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def click(cookies_get, id): def click(cookies_get, id):
try:
post_dict = { post_dict = {
'type': 1, 'type': 1,
'id': id 'id': id
...@@ -81,9 +93,15 @@ def click(cookies_get, id): ...@@ -81,9 +93,15 @@ def click(cookies_get, id):
cookies=cookies_get, cookies=cookies_get,
data=post_dict) 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 follow(cookies_get, id): def follow(cookies_get, id):
try:
post_dict = { post_dict = {
'type': 1, 'type': 1,
'id': id 'id': id
...@@ -94,47 +112,56 @@ def follow(cookies_get, id): ...@@ -94,47 +112,56 @@ def follow(cookies_get, id):
print(response.text, 'url') 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): def time_conv(numtime):
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:
return None
def get_star_user_id(numtime): def get_star_user_id(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
print("---------")
cursor.execute( cursor.execute(
"SELECT user_id FROM topic WHERE content_level =4 or content_level =5 and create_time LIKE '%%%%%s%%%%'" % numtime) "SELECT user_id FROM topic WHERE 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)
print("Database version : %s " % user_id) logging.info("Database version : %s " % data)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
def get_star_topic_id(numtime): def get_star_topic_id(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute( cursor.execute(
"SELECT id FROM topic WHERE content_level =4 or content_level =5 and create_time LIKE '%%%%%s%%%%'" % numtime) "SELECT id FROM topic WHERE 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 " % data)
print("Database version : %s " % user_id)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__": if __name__ == "__main__":
try:
numtime = time_conv(1) numtime = time_conv(1)
topic_id = get_star_topic_id(numtime) topic_id = get_star_topic_id(numtime)
...@@ -173,3 +200,6 @@ if __name__ == "__main__": ...@@ -173,3 +200,6 @@ if __name__ == "__main__":
# time.sleep(random.randint(500, 1000)) # time.sleep(random.randint(500, 1000))
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -4,21 +4,30 @@ import datetime ...@@ -4,21 +4,30 @@ import datetime
import pymysql import pymysql
import random import random
import pandas as pd import pandas as pd
import traceback
from log_settings import *
import logging
auto_urge_url = "http://earth.igengmei.com/api/v1/user/urge" auto_urge_url = "http://earth.igengmei.com/api/v1/user/urge"
login_url = "http://earth.igengmei.com/api/account/login_pwd" login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first(): def index_first():
try:
r1=requests.get(login_url) r1 = requests.get(login_url)
return r1.cookies.get_dict() return r1.cookies.get_dict()
except:
logging.error("index_first:%s" % traceback.format_exc())
return None
def get_majia(): def get_majia():
try:
data = open("batch user gen") data = open("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(','))
...@@ -28,12 +37,15 @@ def get_majia(): ...@@ -28,12 +37,15 @@ def get_majia():
user_id=list[maj-1] user_id=list[maj-1]
print(user_id)
return user_id return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins(): def logins():
try:
# time.sleep(random.randint(300, 500)) # time.sleep(random.randint(300, 500))
user_id=get_majia() user_id=get_majia()
...@@ -57,13 +69,19 @@ def logins(): ...@@ -57,13 +69,19 @@ def logins():
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
print(response.text, 'url') logging.info("response.text :%s" % response.text)
print(cook)
return {'sessionid': cook} return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def Urge(cookies_get, id): def Urge(cookies_get, id):
try:
post_dict = { post_dict = {
'id': id 'id': id
} }
...@@ -73,52 +91,56 @@ def Urge(cookies_get, id): ...@@ -73,52 +91,56 @@ def Urge(cookies_get, id):
print(response.text, 'url') 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): def time_conv(numtime):
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')
print(now)
return yes_time_str return yes_time_str
except:
return None
def get_data(numtime): def get_data(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
print("---------")
cursor.execute("SELECT distinct(user_id) FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute("SELECT distinct(user_id) FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % data)
print("Database version : %s " % user_id)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
def get_star_useid(numtime): def get_star_useid(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute( cursor.execute(
"SELECT user_id FROM topic WHERE content_level =4 or content_level =5 and create_time LIKE '%%%%%s%%%%'" % numtime) "SELECT user_id FROM topic WHERE 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 " % data)
print("Database version : %s " % user_id)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__": if __name__ == "__main__":
try:
time_list = [1,2,3,4,5,6,7] time_list = [1,2,3,4,5,6,7]
for i in time_list: for i in time_list:
...@@ -163,3 +185,6 @@ if __name__ == "__main__": ...@@ -163,3 +185,6 @@ if __name__ == "__main__":
Urge(cookies, id) Urge(cookies, id)
# time.sleep(random.randint(500, 1000)) # time.sleep(random.randint(500, 1000))
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
\ No newline at end of file
...@@ -3,28 +3,31 @@ import time ...@@ -3,28 +3,31 @@ import time
import datetime import datetime
import pymysql import pymysql
import random import random
import traceback
# s = requests.session() from log_settings import *
# import logging
# s.keep_alive = False
#
# requests.adapters.DEFAULT_RETRIES = 5
auto_pick_url = "http://earth.igengmei.com/api/v1/pick/do_pick" auto_pick_url = "http://earth.igengmei.com/api/v1/pick/do_pick"
login_url = "http://earth.igengmei.com/api/account/login_pwd" login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first(): def index_first():
try:
r1 = requests.get(login_url) r1 = requests.get(login_url)
return r1.cookies.get_dict() return r1.cookies.get_dict()
except:
logging.error("index_first:%s" % traceback.format_exc())
return None
def get_majia(): def get_majia():
try:
data = open("batch user gen") data = open("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(','))
...@@ -34,18 +37,17 @@ def get_majia(): ...@@ -34,18 +37,17 @@ def get_majia():
user_id=list[maj-1] user_id=list[maj-1]
print(user_id)
return user_id return user_id
def logins(): except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins():
try:
# time.sleep(random.randint(300, 500)) # time.sleep(random.randint(300, 500))
user_id=get_majia() user_id=get_majia()
cookies = index_first() cookies = index_first()
post_dict={ post_dict={
'account_type':2, 'account_type':2,
'pwd':'123456', 'pwd':'123456',
...@@ -56,53 +58,62 @@ def logins(): ...@@ -56,53 +58,62 @@ def logins():
data=post_dict, data=post_dict,
cookies=cookies cookies=cookies
) )
headers=response.headers headers=response.headers
cook = headers['Set-Cookie'].split(";") cook = headers['Set-Cookie'].split(";")
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
logging.info("response.text :%s" % response.text)
print(response.text, 'url')
print(cook)
return {'sessionid': cook} return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def pick(cookies_get,id): def pick(cookies_get,id):
post_dict={
'pick_user_id':id, try:
'is_pick':1, post_dict = {
'pick_type':0 'pick_user_id': id,
'is_pick': 1,
'pick_type': 0
} }
response=requests.post(url=auto_pick_url, response = requests.post(url=auto_pick_url,
cookies=cookies_get, cookies=cookies_get,
data=post_dict) data=post_dict)
print(response.headers)
print(response.text, 'url') 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): def time_conv(numtime):
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:
return None
def get_data(numtime): def get_data(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
print("---------")
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
print("Database version : %s " % user_id) logging.info("Database version : %s " % data)
db.close() db.close()
return user_id return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__": if __name__ == "__main__":
try:
# time.sleep(random.randint(3000,4500)) # time.sleep(random.randint(3000,4500))
numtime = time_conv(3) numtime = time_conv(3)
...@@ -120,6 +131,9 @@ if __name__ == "__main__": ...@@ -120,6 +131,9 @@ if __name__ == "__main__":
pick(cook, id) pick(cook, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment