Commit 4dfd22a1 authored by lixiaofang's avatar lixiaofang

try except

parent 02f87232
This diff is collapsed.
......@@ -4,196 +4,247 @@ import datetime
import pymysql
import random
import pandas as pd
import traceback
from log_settings import *
import logging
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"
login_url = "http://earth.igengmei.com/api/account/login_pwd"
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():
data = open("batch user gen")
try:
data = open("batch user gen")
list=[]
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
for i in data:
list.append(i.strip('\n').strip(','))
# time.sleep(random.randint(0, 500))
# time.sleep(random.randint(0, 500))
maj = random.randint(1,len(list))
maj = random.randint(1,len(list))
user_id=list[maj-1]
user_id=list[maj-1]
return user_id
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def login():
# time.sleep(random.randint(300, 500))
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
user_id=get_majia()
cookies = index_first()
cookies = index_first()
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
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)
print(cook)
return {'sessionid': cook}
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def logins(id):
cookies = index_first()
try:
cookies = index_first()
post_dict={
'account_type':2,
'pwd':'123456',
'email':id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
post_dict={
'account_type':2,
'pwd':'123456',
'email':id
}
response = requests.post(
url=login_url,
data=post_dict,
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')
return {'sessionid': cook}
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
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 click(cookies_get, id):
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_click_url,
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
try:
post_dict = {
'type': 1,
'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):
post_dict={
'topic_id':id,
'content':content
}
response=requests.post(url=auto_reply_url,
try:
post_dict={
'topic_id':id,
'content':content
}
response=requests.post(url=auto_reply_url,
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
logging.info("response.text:%s" % response.text)
def time_conv():
except:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(minutes=15)
print(yes_time)
return yes_time
logging.error("catch exception,logins:%s" % traceback.format_exc())
def get_topic_id(numtime):
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
cursor.execute("SELECT id FROM topic WHERE create_time >= %s" ,(numtime))
data = cursor.fetchall()
user_id = list(data)
print("Database version : %s " % user_id)
def time_conv():
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(minutes=15)
print(yes_time)
return yes_time
db.close()
except:
return None
return user_id
def get_topic_id(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute("SELECT id FROM topic WHERE create_time >= %s" ,(numtime))
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
def get_comment():
try:
data = pd.read_csv("guanshui", sep='\n')
num = random.randint(0, len(data))
list_guanshui = []
for i in data['comment scene']:
l = i.split('\t')
list_guanshui.append(l[0])
data = pd.read_csv("guanshui", sep='\n')
num = random.randint(0, len(data))
list_guanshui = []
for i in data['comment scene']:
l = i.split('\t')
list_guanshui.append(l[0])
comment = list_guanshui[num-1]
comment = list_guanshui[num-1]
return comment
return comment
except:
if __name__ == "__main__":
return None
numtime=time_conv()
if __name__ == "__main__":
try:
topic_id = get_topic_id(numtime)
numtime=time_conv()
for j in topic_id:
topic_id = get_topic_id(numtime)
id = int(j[0])
for j in topic_id:
click_num = random.randint(1,5)
id = int(j[0])
for i in range(click_num):
click_num = random.randint(1,5)
# time.sleep(random.randint(500, 1500))
for i in range(click_num):
cookies = login()
# time.sleep(random.randint(500, 1500))
click(cookies, id)
cookies = login()
# time.sleep(random.randint(500, 1500))
topic_id = get_topic_id(numtime)
click(cookies, id)
for j in topic_id:
# time.sleep(random.randint(500, 1500))
topic_id = get_topic_id(numtime)
id = int(j[0])
for j in topic_id:
comment_num = random.randint(1, 3)
id = int(j[0])
for i in range(comment_num):
comment_num = random.randint(1, 3)
# time.sleep(random.randint(500, 1500))
for i in range(comment_num):
cookies= login()
# time.sleep(random.randint(500, 1500))
comment = get_comment()
cookies= login()
reply(cookies, id, comment)
comment = get_comment()
reply(cookies, id, comment)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -3,7 +3,9 @@ import time
import datetime
import pymysql
import random
import traceback
from log_settings import *
import logging
# s = requests.session()
#
# s.keep_alive = False
......@@ -15,129 +17,154 @@ auto_click_url = "http://earth.igengmei.com/api/v1/like"
login_url = "http://earth.igengmei.com/api/account/login_pwd"
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():
data = open("batch user gen")
try:
data = open("batch user gen")
list=[]
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
for i in data:
list.append(i.strip('\n').strip(','))
# time.sleep(random.randint(0, 500))
# time.sleep(random.randint(0, 500))
maj = random.randint(1,len(list))
maj = random.randint(1,len(list))
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():
# time.sleep(random.randint(300, 500))
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
user_id=get_majia()
cookies = index_first()
cookies = index_first()
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
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')
return {'sessionid': cook}
print(cook)
except:
return {'sessionid': cook}
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def click(cookies_get, id):
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_click_url,
cookies=cookies_get,
data=post_dict)
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_click_url,
cookies=cookies_get,
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())
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
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):
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
print("Database version : %s " % user_id)
db.close()
return user_id
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
time_list = [1,2,3,4,5,6,7]
try:
for i in time_list:
time_list = [1,2,3,4,5,6,7]
#time.sleep(random.randint(3000,4500))
for i in time_list:
numtime = time_conv(i)
#time.sleep(random.randint(3000,4500))
user_id = get_data(numtime)
numtime = time_conv(i)
dict = {}
user_id = get_data(numtime)
for i in user_id:
dict = {}
if i[0] not in dict.keys():
dict.setdefault(i[0], [])
dict[i[0]].append(i[1])
for i in user_id:
else:
dict[i[0]].append(i[1])
if i[0] not in dict.keys():
dict.setdefault(i[0], [])
dict[i[0]].append(i[1])
for key,value in dict.items():
else:
dict[i[0]].append(i[1])
rand_num = random.randint(0,len(value)-1)
for key,value in dict.items():
rand_id = value[rand_num]
rand_num = random.randint(0,len(value)-1)
urge_num = random.randint(0, 1)
rand_id = value[rand_num]
for i in range(urge_num):
urge_num = random.randint(0, 1)
cook=login()
for i in range(urge_num):
click(cook, rand_id)
cook=login()
click(cook, rand_id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
......@@ -3,131 +3,162 @@ import time
import datetime
import pymysql
import random
import traceback
from log_settings import *
import logging
auto_click_url = "http://earth.igengmei.com/api/v1/like"
login_url = "http://earth.igengmei.com/api/account/login_pwd"
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():
data = open("batch user gen")
try:
data = open("batch user gen")
list=[]
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
for i in data:
list.append(i.strip('\n').strip(','))
# time.sleep(random.randint(0, 500))
# time.sleep(random.randint(0, 500))
maj = random.randint(1,len(list))
maj = random.randint(1,len(list))
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():
# time.sleep(random.randint(300, 500))
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
user_id=get_majia()
cookies = index_first()
cookies = index_first()
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
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)
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):
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_click_url,
cookies=cookies_get,
data=post_dict)
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_click_url,
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
logging.info("response.text:%s" % response.text)
def time_conv(numtime):
except:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
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):
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
print("Database version : %s " % user_id)
db.close()
return user_id
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
time_list = [1,2,3,4,5,6,7]
try:
time_list = [1,2,3,4,5,6,7]
for i in time_list:
for i in time_list:
#time.sleep(random.randint(3000,4500))
#time.sleep(random.randint(3000,4500))
numtime = time_conv(7+3*i)
numtime = time_conv(7+3*i)
user_id = get_data(numtime)
user_id = get_data(numtime)
dict = {}
dict = {}
for i in user_id:
for i in user_id:
if i[0] not in dict.keys():
dict.setdefault(i[0], [])
dict[i[0]].append(i[1])
if i[0] not in dict.keys():
dict.setdefault(i[0], [])
dict[i[0]].append(i[1])
else:
dict[i[0]].append(i[1])
else:
dict[i[0]].append(i[1])
for key,value in dict.items():
for key,value in dict.items():
rand_num = random.randint(0,len(value)-1)
rand_num = random.randint(0,len(value)-1)
rand_id = value[rand_num]
rand_id = value[rand_num]
urge_num = random.randint(0, 1)
urge_num = random.randint(0, 1)
for i in range(urge_num):
for i in range(urge_num):
cook=logins()
cook=logins()
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,121 +3,146 @@ import time
import datetime
import pymysql
import random
# s = requests.session()
#
# s.keep_alive = False
#
# requests.adapters.DEFAULT_RETRIES = 5
import traceback
from log_settings import *
import logging
auto_follow_url = "http://earth.igengmei.com/api/v1/follow"
login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first():
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
logging.error("index_first:%s" % traceback.format_exc())
r1=requests.get(login_url)
return None
return r1.cookies.get_dict()
def get_majia():
data = open("batch user gen")
try:
data = open("batch user gen")
list=[]
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
for i in data:
list.append(i.strip('\n').strip(','))
# time.sleep(random.randint(0, 500))
# time.sleep(random.randint(0, 500))
maj = random.randint(1,len(list))
maj = random.randint(1,len(list))
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():
# time.sleep(random.randint(300, 500))
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
user_id=get_majia()
cookies = index_first()
cookies = index_first()
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
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')
return {'sessionid': cook}
print(cook)
except:
return {'sessionid': cook}
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_click_url,
cookies=cookies_get,
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())
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
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):
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
print("Database version : %s " % user_id)
db.close()
return user_id
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
try:
#time.sleep(random.randint(3000,4500))
#time.sleep(random.randint(3000,4500))
numtime = time_conv(3)
numtime = time_conv(3)
user_id = get_data(numtime)
user_id = get_data(numtime)
for i in user_id:
for i in user_id:
urge_num = random.randint(1,2)
urge_num = random.randint(1,2)
for i in range(urge_num):
for i in range(urge_num):
cookies = index_first()
cookies = index_first()
cook=logins()
cook=logins()
follow(cook, id)
follow(cook, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
......@@ -76,10 +76,6 @@ def logins():
cook = cook[0].split('=')[1]
print(response.text, 'url')
print(cook)
return {'sessionid': cook}
except:
......@@ -98,7 +94,6 @@ def reply(cookies_get,id,content):
cookies=cookies_get,
data=post_dict)
print(response.text,'url')
logging.info("response.text :%s"%(response.text))
except:
......@@ -115,11 +110,9 @@ def time_conv(numtime):
return None
def get_topic_id(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db="alpha", port=3306)
cursor = db.cursor()
# print("---------")
cursor.execute("SELECT id FROM topic WHERE create_time LIKE '%%%%%s%%%%' " %numtime)
data = cursor.fetchall()
topic_id = list(data)
......@@ -127,6 +120,7 @@ def get_topic_id(numtime):
db.close()
return topic_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
def get_comment():
......
......@@ -3,7 +3,9 @@ import time
import datetime
import pymysql
import random
import traceback
from log_settings import *
import logging
auto_follow_url = "http://earth.igengmei.com/api/v1/follow"
login_url = "http://earth.igengmei.com/api/account/login_pwd"
......@@ -11,166 +13,201 @@ login_url = "http://earth.igengmei.com/api/account/login_pwd"
auto_pick_url = "http://earth.igengmei.com/api/v1/pick/do_pick"
def index_first():
r1=requests.get(login_url)
return r1.cookies.get_dict()
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
logging.error("index_first:%s" % traceback.format_exc())
return None
def get_majia():
data = open("batch user gen")
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
list=[]
# time.sleep(random.randint(0, 500))
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list))
# time.sleep(random.randint(0, 500))
user_id=list[maj-1]
maj = random.randint(1,len(list))
print(user_id)
user_id=list[maj-1]
return user_id
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins():
# time.sleep(random.randint(300, 500))
try:
user_id=get_majia()
# time.sleep(random.randint(300, 500))
cookies = index_first()
user_id=get_majia()
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
cookies = index_first()
headers=response.headers
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
cook = headers['Set-Cookie'].split(";")
headers=response.headers
cook = cook[0].split('=')[1]
cook = headers['Set-Cookie'].split(";")
print(response.text, 'url')
cook = cook[0].split('=')[1]
print(cook)
logging.info("response.text :%s" %response.text)
return {'sessionid': cook}
return {'sessionid': cook}
def follow(cookies_get, id):
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
except:
print(response.text, 'url')
logging.error("catch exception,logins:%s" % traceback.format_exc())
def pick(cookies_get,id):
post_dict={
'pick_user_id':id,
'is_pick':1,
'pick_type':0
}
response=requests.post(url=auto_pick_url,
cookies=cookies_get,
data=post_dict)
return None
def follow(cookies_get, id):
print(response.headers)
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)
def time_conv(numtime):
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
print(now)
return yes_time_str
except:
def get_topic_new_user(numtime):
logging.error("catch exception,logins:%s" % traceback.format_exc())
def pick(cookies_get,id):
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
try:
post_dict = {
'pick_user_id': id,
'is_pick': 1,
'pick_type': 0
}
response = requests.post(url=auto_pick_url,
cookies=cookies_get,
data=post_dict)
cursor.execute("SELECT user_id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
topic_data = cursor.fetchall()
logging.info("response.text:%s" % response.text)
cursor.execute("SELECT user_id FROM group_user_role WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
new_user_data = cursor.fetchall()
except:
topic_data = list(topic_data)
new_user_data = list(new_user_data)
logging.error("catch exception,logins:%s" % traceback.format_exc())
user_id = []
def time_conv(numtime):
for i in topic_data:
user_id.append(i)
for i in new_user_data:
user_id.append(i)
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
print("Database version : %s " % user_id)
db.close()
return user_id
def get_topic_new_user(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute("SELECT user_id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
topic_data = cursor.fetchall()
cursor.execute("SELECT user_id FROM group_user_role WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
new_user_data = cursor.fetchall()
topic_data = list(topic_data)
new_user_data = list(new_user_data)
user_id = []
for i in topic_data:
user_id.append(i)
for i in new_user_data:
user_id.append(i)
logging.info("Database version : %s " % user_id)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
def get_topic_data(numtime):
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
print("Database version : %s " % user_id)
db.close()
return user_id
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
try:
numtime = time_conv(0)
numtime = time_conv(0)
user_id = get_topic_new_user(numtime)
user_id = get_topic_new_user(numtime)
for j in user_id:
for j in user_id:
id = int(j[0])
id = int(j[0])
follow_num = random.randint(1,2)
follow_num = random.randint(1,2)
for i in range(follow_num):
for i in range(follow_num):
# time.sleep(random.randint(500, 1500))
# time.sleep(random.randint(500, 1500))
cookies=logins()
cookies=logins()
follow(cookies, id)
follow(cookies, id)
user_id = get_topic_data(numtime)
user_id = get_topic_data(numtime)
for j in user_id:
for j in user_id:
id = int(j[0])
id = int(j[0])
follow_num = random.randint(1,10)
follow_num = random.randint(1,10)
for i in range(follow_num):
for i in range(follow_num):
# time.sleep(random.randint(500, 1500))
# time.sleep(random.randint(500, 1500))
cookies = logins()
cookies = logins()
pick(cookies, id)
pick(cookies, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
......@@ -3,97 +3,122 @@ import time
import datetime
import pymysql
import random
import traceback
from log_settings import *
import logging
auto_follow_url = "http://earth.igengmei.com/api/v1/follow"
login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first():
r1=requests.get(login_url)
return r1.cookies.get_dict()
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
logging.error("index_first:%s" % traceback.format_exc())
return None
def get_majia():
data = open("batch user gen")
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
list=[]
# time.sleep(random.randint(0, 500))
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list))
# time.sleep(random.randint(0, 500))
user_id=list[maj-1]
maj = random.randint(1,len(list))
print(user_id)
user_id=list[maj-1]
return user_id
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins():
# time.sleep(random.randint(300, 500))
try:
user_id=get_majia()
# time.sleep(random.randint(300, 500))
cookies = index_first()
user_id=get_majia()
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
cookies = index_first()
headers=response.headers
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
cook = headers['Set-Cookie'].split(";")
headers=response.headers
cook = cook[0].split('=')[1]
cook = headers['Set-Cookie'].split(";")
print(response.text, 'url')
cook = cook[0].split('=')[1]
print(cook)
logging.info("response.text :%s"%response.text)
return {'sessionid': cook}
return {'sessionid': cook}
def follow(cookies_get, id):
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
except:
print(response.text, 'url')
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
print(now)
return yes_time_str
return None
def get_data(numtime):
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
def follow(cookies_get, id):
cursor.execute("SELECT distinct(user_id) FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
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)
user_id = list(data)
except:
print("Database version : %s " % user_id)
db.close()
return user_id
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="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute("SELECT distinct(user_id) FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
def get_commnet_id(numtime):
......@@ -146,54 +171,57 @@ def get_commnet_id(numtime):
if __name__ == "__main__":
time_list = [1,2,3,4,5,6,7,11]
try:
for i in time_list:
time_list = [1,2,3,4,5,6,7,11]
if time_list[i] != 11:
for i in time_list:
numtime = time_conv(i)
if time_list[i] != 11:
user_id = get_data(numtime)
numtime = time_conv(i)
for j in user_id:
user_id = get_data(numtime)
id = int(j[0])
for j in user_id:
follow_num = random.randint(1,2)
id = int(j[0])
for i in range(follow_num):
follow_num = random.randint(1,2)
# time.sleep(random.randint(500, 1500))
for i in range(follow_num):
cookies=logins()
# time.sleep(random.randint(500, 1500))
follow(cookies, id)
cookies=logins()
# time.sleep(random.randint(2000,2500))
follow(cookies, id)
else:
# time.sleep(random.randint(2000,2500))
numtime = time_conv(1)
else:
user_id = get_data(numtime)
numtime = time_conv(1)
for j in user_id:
user_id = get_data(numtime)
id = int(j[0])
for j in user_id:
follow_num = random.randint(0,1)
id = int(j[0])
# time.sleep(random.randint(500, 1500))
follow_num = random.randint(0,1)
for i in range(follow_num):
# time.sleep(random.randint(500, 1500))
cookies = logins()
for i in range(follow_num):
follow(cookies, id)
cookies = logins()
# time.sleep(random.randint(2000, 3000))
follow(cookies, id)
# time.sleep(random.randint(2000, 3000))
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -4,7 +4,9 @@ import datetime
import pymysql
import random
import pandas as pd
import traceback
from log_settings import *
import logging
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"
......@@ -12,123 +14,167 @@ login_url = "http://earth.igengmei.com/api/account/login_pwd"
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 logins(id):
def get_majia():
cookies = index_first()
try:
data = open("batch user gen")
post_dict={
'account_type':2,
'pwd':'123456',
'email':id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
list=[]
headers=response.headers
for i in data:
list.append(i.strip('\n').strip(','))
cook = headers['Set-Cookie'].split(";")
# time.sleep(random.randint(0, 500))
cook = cook[0].split('=')[1]
maj = random.randint(1,len(list))
print(response.text, 'url')
user_id=list[maj-1]
return {'sessionid': cook}
return user_id
def follow(cookies_get, id):
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
print(response.text, 'url')
def logins(user_id):
try:
def time_conv():
# time.sleep(random.randint(300, 500))
cookies = index_first()
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(minutes=15)
return yes_time
post_dict = {
'account_type': 2,
'pwd': '123456',
'email': user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
def get_follw_majia(numtime,id):
headers = response.headers
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
cook = headers['Set-Cookie'].split(";")
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) "
" 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')")
cook = cook[0].split('=')[1]
data = cursor.fetchall()
logging.info("response.text :%s" % response.text)
data=list(data)
return {'sessionid': cook}
print("Database version : %s " % data)
except:
db.close()
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="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
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) "
" 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=list(data)
logging.info("Database version : %s " % data)
db.close()
return data
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
return data
if __name__ == "__main__":
numtime=time_conv()
try:
# get majia zhanghao
numtime=time_conv()
data = get_follw_majia(numtime, id)
# get majia zhanghao
dict_follow_id = {}
data = get_follw_majia(numtime, id)
for j in data:
dict_follow_id = {}
if j[2] != None:
for j in data:
if j[0] not in dict_follow_id.keys():
if j[2] != None:
dict_follow_id.setdefault(j[0], [])
if j[0] not in dict_follow_id.keys():
dict_follow_id[j[0]].append(j[2])
dict_follow_id.setdefault(j[0], [])
else:
dict_follow_id[j[0]].append(j[2])
dict_follow_id[j[0]].append(j[2])
dict_email = {}
else:
dict_follow_id[j[0]].append(j[2])
for j in data:
dict_email = {}
if j[2] != None:
for j in data:
if j[0] not in dict_email.keys():
if j[2] != None:
dict_email.setdefault(j[0], [])
if j[0] not in dict_email.keys():
dict_email[j[0]].append(j[1])
dict_email.setdefault(j[0], [])
else:
dict_email[j[0]].append(j[1])
dict_email[j[0]].append(j[1])
for key, value in dict_follow_id.items():
else:
dict_email[j[0]].append(j[1])
id = dict_email[key][0]
for key, value in dict_follow_id.items():
for i in value:
id = dict_email[key][0]
cookies=logins()
for i in value:
follow(cookies,i)
cookies=logins(id)
follow(cookies,i)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
......@@ -3,13 +3,9 @@ import time
import datetime
import pymysql
import random
# s = requests.session()
#
# s.keep_alive = False
#
# requests.adapters.DEFAULT_RETRIES = 5
import traceback
from log_settings import *
import logging
auto_click_url = "http://earth.igengmei.com/api/v1/like"
login_url = "http://earth.igengmei.com/api/account/login_pwd"
......@@ -19,130 +15,158 @@ auto_pick_url = "http://earth.igengmei.com/api/v1/pick/do_pick"
auto_follow_url = "http://earth.igengmei.com/api/v1/follow"
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():
data = open("batch user gen")
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
list=[]
# time.sleep(random.randint(0, 500))
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list))
# time.sleep(random.randint(0, 500))
user_id=list[maj-1]
maj = random.randint(1,len(list))
print(user_id)
user_id=list[maj-1]
return user_id
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins():
# time.sleep(random.randint(300, 500))
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
user_id=get_majia()
cookies = index_first()
cookies = index_first()
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
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)
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):
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
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)
def pick(cookies_get,id):
post_dict={
'pick_user_id':id,
'is_pick':1,
'pick_type':0
}
response=requests.post(url=auto_pick_url,
cookies=cookies_get,
data=post_dict)
except:
print(response.headers)
logging.error("catch exception,logins:%s" % traceback.format_exc())
print(response.text, 'url')
def pick(cookies_get,id):
def time_conv(numtime):
try:
post_dict = {
'pick_user_id': id,
'is_pick': 1,
'pick_type': 0
}
response = requests.post(url=auto_pick_url,
cookies=cookies_get,
data=post_dict)
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
logging.info("response.text:%s" % response.text)
def get_data(numtime):
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
print("Database version : %s " % user_id)
db.close()
return user_id
except:
if __name__ == "__main__":
logging.error("catch exception,logins:%s" % traceback.format_exc())
#time.sleep(random.randint(3000,4500))
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
numtime = time_conv(1)
def get_data(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % data)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
user_id = get_data(numtime)
if __name__ == "__main__":
try:
for i in user_id:
#time.sleep(random.randint(3000,4500))
id = int(i[0])
numtime = time_conv(1)
urge_num = random.randint(0, 1)
user_id = get_data(numtime)
for i in range(urge_num):
for i in user_id:
cookies = index_first()
id = int(i[0])
cook=logins()
urge_num = random.randint(0, 1)
pick(cook, id)
for i in range(urge_num):
follow(cook,id)
cookies = index_first()
cook=logins()
pick(cook, id)
follow(cook,id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
This diff is collapsed.
......@@ -3,120 +3,146 @@ import time
import datetime
import pymysql
import random
# s = requests.session()
#
# s.keep_alive = False
#
# requests.adapters.DEFAULT_RETRIES = 5
import traceback
from log_settings import *
import logging
auto_urge_url = "http://earth.igengmei.com/api/v1/user/urge"
login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first():
r1 = requests.get(login_url)
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
logging.error("index_first:%s" % traceback.format_exc())
return r1.cookies.get_dict()
return None
def get_majia():
data = open("batch user gen")
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
list=[]
# time.sleep(random.randint(0, 500))
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list))
# time.sleep(random.randint(0, 500))
user_id=list[maj-1]
maj = random.randint(1,len(list))
print(user_id)
user_id=list[maj-1]
return user_id
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins():
# time.sleep(random.randint(300, 500))
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
user_id=get_majia()
cookies = index_first()
cookies = index_first()
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
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')
return {'sessionid': cook}
print(cook)
except:
return {'sessionid': cook}
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def Urge(cookies_get, id):
post_dict = {
'id': id
}
response = requests.post(url=auto_urge_url,
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
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):
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
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):
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
print("Database version : %s " % user_id)
db.close()
return user_id
if __name__ == "__main__":
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % data)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
# time.sleep(random.randint(3000,4500))
if __name__ == "__main__":
try:
numtime = time_conv(3)
# time.sleep(random.randint(3000,4500))
user_id = get_data(numtime)
numtime = time_conv(3)
for i in user_id:
user_id = get_data(numtime)
urge_num = random.randint(1, 2)
for i in user_id:
for i in range(urge_num):
cookies = index_first()
urge_num = random.randint(1, 2)
cook = logins()
for i in range(urge_num):
cookies = index_first()
Urge(cook, id)
cook = logins()
Urge(cook, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
......@@ -3,12 +3,9 @@ import time
import datetime
import pymysql
import random
# s = requests.session()
#
# s.keep_alive = False
#
# requests.adapters.DEFAULT_RETRIES = 5
import traceback
from log_settings import *
import logging
auto_follow_url = "http://earth.igengmei.com/api/v1/follow"
......@@ -17,159 +14,192 @@ auto_click_url = "http://earth.igengmei.com/api/v1/like"
login_url = "http://earth.igengmei.com/api/account/login_pwd"
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():
data = open("batch user gen")
try:
data = open("batch user gen")
list=[]
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
for i in data:
list.append(i.strip('\n').strip(','))
# time.sleep(random.randint(0, 500))
# time.sleep(random.randint(0, 500))
maj = random.randint(1,len(list))
maj = random.randint(1,len(list))
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():
# time.sleep(random.randint(300, 500))
try:
user_id=get_majia()
# time.sleep(random.randint(300, 500))
cookies = index_first()
user_id=get_majia()
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
cookies = index_first()
headers=response.headers
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
cook = headers['Set-Cookie'].split(";")
headers=response.headers
cook = cook[0].split('=')[1]
cook = headers['Set-Cookie'].split(";")
print(response.text, 'url')
cook = cook[0].split('=')[1]
print(cook)
logging.info("response.text :%s" % response.text)
return {'sessionid': cook}
return {'sessionid': cook}
def click(cookies_get, id):
except:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_click_url,
cookies=cookies_get,
data=post_dict)
logging.error("catch exception,logins:%s" % traceback.format_exc())
print(response.text, 'url')
return None
def follow(cookies_get, id):
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
def click(cookies_get, id):
print(response.text, 'url')
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_click_url,
cookies=cookies_get,
data=post_dict)
def time_conv(numtime):
logging.info("response.text:%s" % response.text)
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:
def get_star_user_id(numtime):
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
cursor.execute(
"SELECT user_id FROM topic WHERE content_level =4 or content_level =5 and create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
print("Database version : %s " % user_id)
db.close()
return user_id
logging.error("catch exception,logins:%s" % traceback.format_exc())
def get_star_topic_id(numtime):
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)
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
print(response.text, 'url')
cursor.execute(
"SELECT id FROM topic WHERE content_level =4 or content_level =5 and create_time LIKE '%%%%%s%%%%'" % numtime)
logging.info("response.text:%s" % response.text)
data = cursor.fetchall()
except:
user_id = list(data)
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
print("Database version : %s " % user_id)
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
db.close()
def get_star_user_id(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute(
"SELECT user_id FROM topic WHERE 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 " % data)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
return user_id
def get_star_topic_id(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute(
"SELECT id FROM topic WHERE 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 " % data)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
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)
for j in topic_id:
for j in topic_id:
id = int(j[0])
id = int(j[0])
# time.sleep(random.randint(200,500))
# time.sleep(random.randint(200,500))
urge_num = random.randint(0, 1)
urge_num = random.randint(0, 1)
for i in range(urge_num):
for i in range(urge_num):
cookies = logins()
cookies = logins()
click(cookies, id)
click(cookies, id)
# time.sleep(random.randint(500, 1000))
# time.sleep(random.randint(500, 1000))
user_id = get_star_user_id(numtime)
user_id = get_star_user_id(numtime)
for j in user_id:
for j in user_id:
id = int(j[0])
id = int(j[0])
# time.sleep(random.randint(200,500))
# time.sleep(random.randint(200,500))
urge_num = random.randint(1,2)
urge_num = random.randint(1,2)
for i in range(urge_num):
for i in range(urge_num):
cookies = logins()
cookies = logins()
follow(cookies,id)
follow(cookies,id)
# time.sleep(random.randint(500, 1000))
# time.sleep(random.randint(500, 1000))
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -4,162 +4,187 @@ import datetime
import pymysql
import random
import pandas as pd
import traceback
from log_settings import *
import logging
auto_urge_url = "http://earth.igengmei.com/api/v1/user/urge"
login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first():
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
r1=requests.get(login_url)
return r1.cookies.get_dict()
def get_majia():
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
logging.error("index_first:%s" % traceback.format_exc())
# time.sleep(random.randint(0, 500))
return None
maj = random.randint(1,len(list))
user_id=list[maj-1]
def get_majia():
print(user_id)
try:
data = open("batch user gen")
return user_id
list=[]
def logins():
for i in data:
list.append(i.strip('\n').strip(','))
# time.sleep(random.randint(300, 500))
# time.sleep(random.randint(0, 500))
user_id=get_majia()
maj = random.randint(1,len(list))
cookies = index_first()
user_id=list[maj-1]
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
return user_id
headers=response.headers
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
cook = headers['Set-Cookie'].split(";")
def logins():
cook = cook[0].split('=')[1]
try:
# time.sleep(random.randint(300, 500))
print(response.text, 'url')
user_id=get_majia()
print(cook)
cookies = index_first()
return {'sessionid': cook}
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
def Urge(cookies_get, id):
post_dict = {
'id': id
}
response = requests.post(url=auto_urge_url,
cookies=cookies_get,
data=post_dict)
headers=response.headers
print(response.text, 'url')
cook = headers['Set-Cookie'].split(";")
def time_conv(numtime):
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
print(now)
return yes_time_str
cook = cook[0].split('=')[1]
def get_data(numtime):
logging.info("response.text :%s" % response.text)
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
return {'sessionid': cook}
cursor.execute("SELECT distinct(user_id) FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
except:
user_id = list(data)
logging.error("catch exception,logins:%s" % traceback.format_exc())
print("Database version : %s " % user_id)
return None
db.close()
def Urge(cookies_get, id):
return user_id
try:
post_dict = {
'id': id
}
response = requests.post(url=auto_urge_url,
cookies=cookies_get,
data=post_dict)
def get_star_useid(numtime):
print(response.text, 'url')
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
logging.info("response.text:%s" % response.text)
cursor.execute(
"SELECT user_id FROM topic WHERE content_level =4 or content_level =5 and create_time LIKE '%%%%%s%%%%'" % numtime)
except:
data = cursor.fetchall()
logging.error("catch exception,logins:%s" % traceback.format_exc())
user_id = list(data)
def time_conv(numtime):
print("Database version : %s " % user_id)
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
db.close()
def get_data(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute("SELECT distinct(user_id) FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % data)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
return user_id
def get_star_useid(numtime):
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute(
"SELECT user_id FROM topic WHERE 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 " % data)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
time_list = [1,2,3,4,5,6,7]
try:
time_list = [1,2,3,4,5,6,7]
for i in time_list:
for i in time_list:
numtime = time_conv(i)
numtime = time_conv(i)
user_id = get_data(numtime)
user_id = get_data(numtime)
for j in user_id:
for j in user_id:
id = int(j[0])
id = int(j[0])
# time.sleep(random.randint(200,500))
# time.sleep(random.randint(200,500))
urge_num = random.randint(0, 2)
urge_num = random.randint(0, 2)
for i in range(urge_num):
for i in range(urge_num):
cookies=logins()
cookies=logins()
Urge(cookies, id)
Urge(cookies, id)
# time.sleep(random.randint(500, 1000))
# time.sleep(random.randint(500, 1000))
for i in time_list:
for i in time_list:
numtime = time_conv(i)
numtime = time_conv(i)
user_id = get_star_useid(numtime)
user_id = get_star_useid(numtime)
for j in user_id:
for j in user_id:
id = int(j[0])
id = int(j[0])
# time.sleep(random.randint(200,500))
# time.sleep(random.randint(200,500))
for i in range(1):
for i in range(1):
cookies = logins()
cookies = logins()
Urge(cookies, id)
Urge(cookies, id)
# time.sleep(random.randint(500, 1000))
# time.sleep(random.randint(500, 1000))
\ No newline at end of file
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
\ No newline at end of file
......@@ -3,122 +3,136 @@ import time
import datetime
import pymysql
import random
# s = requests.session()
#
# s.keep_alive = False
#
# requests.adapters.DEFAULT_RETRIES = 5
import traceback
from log_settings import *
import logging
auto_pick_url = "http://earth.igengmei.com/api/v1/pick/do_pick"
login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first():
r1 = requests.get(login_url)
return r1.cookies.get_dict()
def get_majia():
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
# time.sleep(random.randint(0, 500))
logging.error("index_first:%s" % traceback.format_exc())
maj = random.randint(1,len(list))
return None
user_id=list[maj-1]
print(user_id)
def get_majia():
return user_id
try:
data = open("batch user gen")
def logins():
list=[]
# time.sleep(random.randint(300, 500))
for i in data:
list.append(i.strip('\n').strip(','))
user_id=get_majia()
# time.sleep(random.randint(0, 500))
cookies = index_first()
maj = random.randint(1,len(list))
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
user_id=list[maj-1]
headers=response.headers
return user_id
cook = headers['Set-Cookie'].split(";")
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
cook = cook[0].split('=')[1]
def logins():
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
cookies = index_first()
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
headers=response.headers
cook = headers['Set-Cookie'].split(";")
cook = cook[0].split('=')[1]
logging.info("response.text :%s" % response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
print(response.text, 'url')
def pick(cookies_get,id):
print(cook)
try:
post_dict = {
'pick_user_id': id,
'is_pick': 1,
'pick_type': 0
}
response = requests.post(url=auto_pick_url,
cookies=cookies_get,
data=post_dict)
return {'sessionid': cook}
print(response.text, 'url')
def pick(cookies_get,id):
post_dict={
'pick_user_id':id,
'is_pick':1,
'pick_type':0
}
response=requests.post(url=auto_pick_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
print(response.headers)
except:
print(response.text, 'url')
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
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):
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
print("Database version : %s " % user_id)
db.close()
return user_id
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute("SELECT user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % data)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
# time.sleep(random.randint(3000,4500))
try:
# time.sleep(random.randint(3000,4500))
numtime = time_conv(3)
numtime = time_conv(3)
user_id = get_data(numtime)
user_id = get_data(numtime)
for i in user_id:
for i in user_id:
urge_num = random.randint(1, 2)
urge_num = random.randint(1, 2)
for i in range(urge_num):
cookies = index_first()
for i in range(urge_num):
cookies = index_first()
cook = logins()
cook = logins()
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