Commit 4dfd22a1 authored by lixiaofang's avatar lixiaofang

try except

parent 02f87232
This diff is collapsed.
......@@ -4,24 +4,32 @@ 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():
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
......@@ -33,8 +41,14 @@ def get_majia():
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def login():
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
......@@ -58,14 +72,19 @@ def login():
cook = cook[0].split('=')[1]
print(response.text, 'url')
print(cook)
logging.info("response.text :%s"%response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def logins(id):
try:
cookies = index_first()
post_dict={
......@@ -85,11 +104,19 @@ def logins(id):
cook = cook[0].split('=')[1]
print(response.text, 'url')
logging.info("response.text :%s" % response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
......@@ -98,9 +125,15 @@ def follow(cookies_get, id):
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def click(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
......@@ -109,9 +142,15 @@ def click(cookies_get, id):
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def reply(cookies_get,id,content):
try:
post_dict={
'topic_id':id,
'content':content
......@@ -120,33 +159,39 @@ def reply(cookies_get,id,content):
cookies=cookies_get,
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()
yes_time = now - datetime.timedelta(minutes=15)
print(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="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)
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 = []
......@@ -158,7 +203,12 @@ def get_comment():
return comment
except:
return None
if __name__ == "__main__":
try:
numtime=time_conv()
......@@ -196,4 +246,5 @@ if __name__ == "__main__":
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,16 +17,22 @@ 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():
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
......@@ -34,12 +42,15 @@ def get_majia():
user_id=list[maj-1]
print(user_id)
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def login():
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
......@@ -63,14 +74,18 @@ def login():
cook = cook[0].split('=')[1]
print(response.text, 'url')
print(cook)
logging.info("response.text %s"%response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def click(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
......@@ -79,29 +94,40 @@ def click(cookies_get, id):
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())
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()
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)
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_list = [1,2,3,4,5,6,7]
for i in time_list:
......@@ -137,7 +163,8 @@ if __name__ == "__main__":
click(cook, rand_id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
......@@ -3,22 +3,30 @@ 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():
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
......@@ -28,12 +36,16 @@ def get_majia():
user_id=list[maj-1]
print(user_id)
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins():
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
......@@ -57,14 +69,18 @@ def logins():
cook = cook[0].split('=')[1]
print(response.text, 'url')
print(cook)
logging.info("response.text : %s"%response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def click(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
......@@ -73,16 +89,23 @@ def click(cookies_get, id):
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())
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()
......@@ -90,12 +113,18 @@ def get_data(numtime):
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)
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_list = [1,2,3,4,5,6,7]
for i in time_list:
......@@ -131,3 +160,5 @@ if __name__ == "__main__":
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
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:
r1=requests.get(login_url)
logging.error("index_first:%s" % traceback.format_exc())
return None
return r1.cookies.get_dict()
def get_majia():
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
......@@ -34,12 +38,16 @@ def get_majia():
user_id=list[maj-1]
print(user_id)
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins():
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
......@@ -63,43 +71,57 @@ def logins():
cook = cook[0].split('=')[1]
print(response.text, 'url')
print(cook)
logging.info("response.text %s"%response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
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())
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()
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)
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))
......@@ -119,6 +141,9 @@ if __name__ == "__main__":
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,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"
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 None
def get_majia():
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
......@@ -28,12 +39,16 @@ def get_majia():
user_id=list[maj-1]
print(user_id)
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins():
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
......@@ -57,13 +72,19 @@ def logins():
cook = cook[0].split('=')[1]
print(response.text, 'url')
print(cook)
logging.info("response.text :%s" %response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
......@@ -72,70 +93,84 @@ def follow(cookies_get, id):
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def pick(cookies_get,id):
post_dict={
'pick_user_id':id,
'is_pick':1,
'pick_type':0
try:
post_dict = {
'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,
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):
try:
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:
return None
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()
print("---------")
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)
print("Database version : %s " % user_id)
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):
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)
print("Database version : %s " % user_id)
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)
......@@ -171,6 +206,8 @@ if __name__ == "__main__":
cookies = logins()
pick(cookies, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
......@@ -3,20 +3,30 @@ 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)
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():
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
......@@ -26,12 +36,16 @@ def get_majia():
user_id=list[maj-1]
print(user_id)
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins():
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
......@@ -55,13 +69,19 @@ def logins():
cook = cook[0].split('=')[1]
print(response.text, 'url')
print(cook)
logging.info("response.text :%s"%response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
......@@ -70,30 +90,35 @@ def follow(cookies_get, id):
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
print(now)
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()
print("---------")
cursor.execute("SELECT distinct(user_id) FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
print("Database version : %s " % user_id)
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,6 +171,8 @@ def get_commnet_id(numtime):
if __name__ == "__main__":
try:
time_list = [1,2,3,4,5,6,7,11]
for i in time_list:
......@@ -194,6 +221,7 @@ if __name__ == "__main__":
# 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,19 +14,48 @@ 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():
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()
post_dict={
'account_type':2,
'pwd':'123456',
'email':id
post_dict = {
'account_type': 2,
'pwd': '123456',
'email': user_id
}
response = requests.post(
url=login_url,
......@@ -32,17 +63,26 @@ def logins(id):
cookies=cookies
)
headers=response.headers
headers = response.headers
cook = headers['Set-Cookie'].split(";")
cook = cook[0].split('=')[1]
print(response.text, 'url')
logging.info("response.text :%s" % response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
......@@ -51,37 +91,42 @@ def follow(cookies_get, id):
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv():
def time_conv():
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(minutes=15)
return yes_time
def get_follw_majia(numtime,id):
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()
print("---------")
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')")
" 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)
print("Database version : %s " % data)
logging.info("Database version : %s " % data)
db.close()
return data
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
try:
numtime=time_conv()
# get majia zhanghao
......@@ -124,11 +169,12 @@ if __name__ == "__main__":
for i in value:
cookies=logins()
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,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"
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(','))
......@@ -38,12 +40,16 @@ def get_majia():
user_id=list[maj-1]
print(user_id)
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins():
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
......@@ -67,13 +73,18 @@ def logins():
cook = cook[0].split('=')[1]
print(response.text, 'url')
print(cook)
logging.info("response.text :%s" % response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
......@@ -82,42 +93,56 @@ def follow(cookies_get, id):
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def pick(cookies_get,id):
post_dict={
'pick_user_id':id,
'is_pick':1,
'pick_type':0
try:
post_dict = {
'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,
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()
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()
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)
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:
#time.sleep(random.randint(3000,4500))
......@@ -140,9 +165,8 @@ if __name__ == "__main__":
pick(cook, id)
follow(cook,id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
......@@ -3,22 +3,30 @@ import time
import datetime
import pymysql
import random
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():
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(','))
......@@ -28,12 +36,16 @@ def get_majia():
user_id=list[maj-1]
print(user_id)
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def login():
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
......@@ -57,14 +69,20 @@ def login():
cook = cook[0].split('=')[1]
print(response.text, 'url')
print(cook)
logging.info("response.text :%s" % response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def logins(id):
try:
cookies = index_first()
post_dict={
......@@ -84,95 +102,94 @@ def logins(id):
cook = cook[0].split('=')[1]
print(response.text, 'url')
logging.info("response.text :%s" % response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def pick(cookies_get,id):
post_dict={
'pick_user_id':id,
'is_pick':1,
'pick_type':0
try:
post_dict = {
'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,
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()
yes_time = now -datetime.timedelta(days=numtime)
yes_time_str=yes_time.strftime('%Y-%m-%d')
print(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()
print("---------")
cursor.execute("SELECT distinct(user_id) FROM topic WHERE create_time LIKE '%%%%%s%%%%'" %numtime)
data = cursor.fetchall()
user_id = list(data)
print("Database version : %s " % user_id)
logging.info("Database version : %s " % data)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
def get_new_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()
print("---------")
cursor.execute(
"select user_id from account_user WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data_new_user = cursor.fetchall()
data3_id = list(data_new_user)
print("Database version : %s " % user_id)
data = list(data_new_user)
logging.info("Database version : %s " % data)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
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)
print("Database version : %s " % user_id)
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:
time_list = [1,2,3,4,5,6,7]
#topic
......@@ -247,4 +264,5 @@ if __name__ == "__main__":
pick(cookies, i)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -3,28 +3,31 @@ 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():
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():
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
......@@ -34,12 +37,16 @@ def get_majia():
user_id=list[maj-1]
print(user_id)
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins():
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
......@@ -63,13 +70,19 @@ def logins():
cook = cook[0].split('=')[1]
print(response.text, 'url')
print(cook)
logging.info("response.text :%s" % response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def Urge(cookies_get, id):
try:
post_dict = {
'id': id
}
......@@ -77,27 +90,39 @@ def Urge(cookies_get, id):
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_data(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 user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
print("Database version : %s " % user_id)
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:
# time.sleep(random.randint(3000,4500))
......@@ -116,7 +141,8 @@ if __name__ == "__main__":
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,16 +14,22 @@ 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():
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
......@@ -36,12 +39,16 @@ def get_majia():
user_id=list[maj-1]
print(user_id)
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins():
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
......@@ -65,14 +72,19 @@ def logins():
cook = cook[0].split('=')[1]
print(response.text, 'url')
print(cook)
logging.info("response.text :%s" % response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def click(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
......@@ -81,9 +93,15 @@ def click(cookies_get, id):
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
......@@ -94,47 +112,56 @@ def follow(cookies_get, id):
print(response.text, 'url')
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_star_user_id(numtime):
try:
db = pymysql.connect(host="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)
logging.info("Database version : %s " % data)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
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)
print("Database version : %s " % user_id)
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)
topic_id = get_star_topic_id(numtime)
......@@ -173,3 +200,6 @@ if __name__ == "__main__":
# time.sleep(random.randint(500, 1000))
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -4,21 +4,30 @@ 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():
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 None
def get_majia():
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
......@@ -28,12 +37,15 @@ def get_majia():
user_id=list[maj-1]
print(user_id)
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def logins():
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
......@@ -57,13 +69,19 @@ def logins():
cook = cook[0].split('=')[1]
print(response.text, 'url')
print(cook)
logging.info("response.text :%s" % response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def Urge(cookies_get, id):
try:
post_dict = {
'id': id
}
......@@ -73,52 +91,56 @@ def Urge(cookies_get, id):
print(response.text, 'url')
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
print(now)
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()
print("---------")
cursor.execute("SELECT distinct(user_id) FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
print("Database version : %s " % user_id)
logging.info("Database version : %s " % data)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
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)
print("Database version : %s " % user_id)
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:
time_list = [1,2,3,4,5,6,7]
for i in time_list:
......@@ -163,3 +185,6 @@ if __name__ == "__main__":
Urge(cookies, id)
# 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
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():
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():
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
......@@ -34,18 +37,17 @@ def get_majia():
user_id=list[maj-1]
print(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))
user_id=get_majia()
cookies = index_first()
post_dict={
'account_type':2,
'pwd':'123456',
......@@ -56,53 +58,62 @@ def logins():
data=post_dict,
cookies=cookies
)
headers=response.headers
cook = headers['Set-Cookie'].split(";")
cook = cook[0].split('=')[1]
print(response.text, 'url')
print(cook)
logging.info("response.text :%s" % response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def pick(cookies_get,id):
post_dict={
'pick_user_id':id,
'is_pick':1,
'pick_type':0
try:
post_dict = {
'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,
data=post_dict)
print(response.headers)
print(response.text, 'url')
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_data(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 user_id,id FROM topic WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
print("Database version : %s " % user_id)
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:
# time.sleep(random.randint(3000,4500))
numtime = time_conv(3)
......@@ -120,6 +131,9 @@ if __name__ == "__main__":
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