Commit e5b7e34f authored by lixiaofang's avatar lixiaofang

cookies

parent 1ffd3535
This diff is collapsed.
...@@ -74,7 +74,11 @@ def login(): ...@@ -74,7 +74,11 @@ def login():
logging.info("response.text :%s"%response.text) logging.info("response.text :%s"%response.text)
return {'sessionid': cook} cok = {'sessionid': cook}
if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -106,7 +110,9 @@ def logins(id): ...@@ -106,7 +110,9 @@ def logins(id):
logging.info("response.text :%s" % response.text) logging.info("response.text :%s" % response.text)
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -243,8 +249,10 @@ if __name__ == "__main__": ...@@ -243,8 +249,10 @@ if __name__ == "__main__":
cookies= login() cookies= login()
comment = get_comment() if cookies is not None:
comment = get_comment()
reply(cookies, id, comment) reply(cookies, id, comment)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -76,7 +76,9 @@ def login(): ...@@ -76,7 +76,9 @@ def login():
logging.info("response.text %s"%response.text) logging.info("response.text %s"%response.text)
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -161,7 +163,9 @@ if __name__ == "__main__": ...@@ -161,7 +163,9 @@ if __name__ == "__main__":
cook=login() cook=login()
click(cook, rand_id) if cook is not None:
click(cook, rand_id)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
......
...@@ -71,7 +71,9 @@ def logins(): ...@@ -71,7 +71,9 @@ def logins():
logging.info("response.text : %s"%response.text) logging.info("response.text : %s"%response.text)
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -158,7 +160,9 @@ if __name__ == "__main__": ...@@ -158,7 +160,9 @@ if __name__ == "__main__":
cook=logins() cook=logins()
click(cook, rand_id) if cook is not None:
click(cook, rand_id)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
\ No newline at end of file
...@@ -21,7 +21,6 @@ def index_first(): ...@@ -21,7 +21,6 @@ def index_first():
return None return None
def get_majia(): def get_majia():
try: try:
...@@ -73,7 +72,9 @@ def logins(): ...@@ -73,7 +72,9 @@ def logins():
logging.info("response.text %s"%response.text) logging.info("response.text %s"%response.text)
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -86,7 +87,7 @@ def follow(cookies_get, id): ...@@ -86,7 +87,7 @@ def follow(cookies_get, id):
'type': 1, 'type': 1,
'id': id 'id': id
} }
response = requests.post(url=auto_click_url, response = requests.post(url=auto_follow_url,
cookies=cookies_get, cookies=cookies_get,
data=post_dict) data=post_dict)
...@@ -139,7 +140,9 @@ if __name__ == "__main__": ...@@ -139,7 +140,9 @@ if __name__ == "__main__":
cook=logins() cook=logins()
follow(cook, id) if cook is not None:
follow(cook, id)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
......
...@@ -78,7 +78,9 @@ def logins(): ...@@ -78,7 +78,9 @@ def logins():
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
......
...@@ -22,7 +22,6 @@ def index_first(): ...@@ -22,7 +22,6 @@ def index_first():
return None return None
def get_majia(): def get_majia():
try: try:
...@@ -74,7 +73,9 @@ def logins(): ...@@ -74,7 +73,9 @@ def logins():
logging.info("response.text :%s" %response.text) logging.info("response.text :%s" %response.text)
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -188,7 +189,9 @@ if __name__ == "__main__": ...@@ -188,7 +189,9 @@ if __name__ == "__main__":
cookies=logins() cookies=logins()
follow(cookies, id) if cookies is not None:
follow(cookies, id)
user_id = get_topic_data(numtime) user_id = get_topic_data(numtime)
...@@ -205,7 +208,9 @@ if __name__ == "__main__": ...@@ -205,7 +208,9 @@ if __name__ == "__main__":
cookies = logins() cookies = logins()
pick(cookies, id) if cookies is not None:
pick(cookies, id)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
......
...@@ -71,7 +71,9 @@ def logins(): ...@@ -71,7 +71,9 @@ def logins():
logging.info("response.text :%s"%response.text) logging.info("response.text :%s"%response.text)
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -195,7 +197,9 @@ if __name__ == "__main__": ...@@ -195,7 +197,9 @@ if __name__ == "__main__":
cookies=logins() cookies=logins()
follow(cookies, id) if cookies is not None:
follow(cookies, id)
# time.sleep(random.randint(2000,2500)) # time.sleep(random.randint(2000,2500))
......
...@@ -71,7 +71,9 @@ def logins(user_id): ...@@ -71,7 +71,9 @@ def logins(user_id):
logging.info("response.text :%s" % response.text) logging.info("response.text :%s" % response.text)
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -79,7 +81,6 @@ def logins(user_id): ...@@ -79,7 +81,6 @@ def logins(user_id):
return None return None
def follow(cookies_get, id): def follow(cookies_get, id):
try: try:
...@@ -97,7 +98,6 @@ def follow(cookies_get, id): ...@@ -97,7 +98,6 @@ def follow(cookies_get, id):
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(): def time_conv():
try: try:
now = datetime.datetime.now() now = datetime.datetime.now()
...@@ -105,6 +105,7 @@ def time_conv(): ...@@ -105,6 +105,7 @@ def time_conv():
return yes_time return yes_time
except: except:
return None return None
def get_follw_majia(numtime): def get_follw_majia(numtime):
try: try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
...@@ -122,7 +123,6 @@ def get_follw_majia(numtime): ...@@ -122,7 +123,6 @@ def get_follw_majia(numtime):
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return None
if __name__ == "__main__": if __name__ == "__main__":
try: try:
...@@ -171,7 +171,9 @@ if __name__ == "__main__": ...@@ -171,7 +171,9 @@ if __name__ == "__main__":
cookies=logins(id) cookies=logins(id)
follow(cookies,i) if cookies is not None:
follow(cookies,i)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
......
...@@ -71,7 +71,9 @@ def logins(): ...@@ -71,7 +71,9 @@ def logins():
logging.info("response.text :%s"%response.text) logging.info("response.text :%s"%response.text)
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -175,9 +177,12 @@ if __name__ == "__main__": ...@@ -175,9 +177,12 @@ if __name__ == "__main__":
# time.sleep(random.randint(500, 1500)) # time.sleep(random.randint(500, 1500))
for i in range(follow_num): for i in range(follow_num):
cookies = logins() cookies = logins()
follow(cookies, id) if cookies is not None:
follow(cookies, id)
# time.sleep(random.randint(2000, 3000)) # time.sleep(random.randint(2000, 3000))
......
...@@ -75,7 +75,9 @@ def logins(): ...@@ -75,7 +75,9 @@ def logins():
logging.info("response.text :%s" % response.text) logging.info("response.text :%s" % response.text)
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -158,13 +160,13 @@ if __name__ == "__main__": ...@@ -158,13 +160,13 @@ if __name__ == "__main__":
for i in range(urge_num): for i in range(urge_num):
cookies = index_first()
cook=logins() cook=logins()
pick(cook, id) if cook is not None:
pick(cook, id)
follow(cook,id) follow(cook,id)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
......
...@@ -104,7 +104,11 @@ def logins(id): ...@@ -104,7 +104,11 @@ def logins(id):
logging.info("response.text :%s" % response.text) logging.info("response.text :%s" % response.text)
return {'sessionid': cook} cok ={'sessionid': cook}
if cok is not None:
return cok
except: except:
...@@ -216,7 +220,9 @@ if __name__ == "__main__": ...@@ -216,7 +220,9 @@ if __name__ == "__main__":
cookies=login() cookies=login()
pick(cookies, id) if cookies is not None:
pick(cookies, id)
# time.sleep(random.randint(500, 1000)) # time.sleep(random.randint(500, 1000))
...@@ -239,7 +245,9 @@ if __name__ == "__main__": ...@@ -239,7 +245,9 @@ if __name__ == "__main__":
cookies = login() cookies = login()
pick(cookies, id) if cookies is not None:
pick(cookies, id)
# time.sleep(random.randint(500, 1000)) # time.sleep(random.randint(500, 1000))
...@@ -265,7 +273,9 @@ if __name__ == "__main__": ...@@ -265,7 +273,9 @@ if __name__ == "__main__":
cookies = logins(id) cookies = logins(id)
pick(cookies, i) if cookies is not None:
pick(cookies, i)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -72,7 +72,9 @@ def logins(): ...@@ -72,7 +72,9 @@ def logins():
logging.info("response.text :%s" % response.text) logging.info("response.text :%s" % response.text)
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -139,7 +141,9 @@ if __name__ == "__main__": ...@@ -139,7 +141,9 @@ if __name__ == "__main__":
cook = logins() cook = logins()
Urge(cook, id) if cook is not None:
Urge(cook, id)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
......
...@@ -71,7 +71,9 @@ def login(): ...@@ -71,7 +71,9 @@ def login():
logging.info("response.text :%s" % response.text) logging.info("response.text :%s" % response.text)
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -104,7 +106,9 @@ def logins(id): ...@@ -104,7 +106,9 @@ def logins(id):
logging.info("response.text :%s" % response.text) logging.info("response.text :%s" % response.text)
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -149,12 +153,12 @@ def get_data(numtime): ...@@ -149,12 +153,12 @@ def get_data(numtime):
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() db.close()
return user_id return user_id
except: except:
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return None
def get_new_user_id(numtime): def get_new_user_id(numtime):
try: try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306) db="alpha", port=3306)
...@@ -213,7 +217,9 @@ if __name__ == "__main__": ...@@ -213,7 +217,9 @@ if __name__ == "__main__":
cookies = login() cookies = login()
pick(cookies, id) if cookies is not None:
pick(cookies, id)
# time.sleep(random.randint(500, 1000)) # time.sleep(random.randint(500, 1000))
...@@ -239,7 +245,9 @@ if __name__ == "__main__": ...@@ -239,7 +245,9 @@ if __name__ == "__main__":
cookies = logins(id) cookies = logins(id)
pick(cookies, i) if cookies is not None:
pick(cookies, i)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -74,7 +74,9 @@ def logins(): ...@@ -74,7 +74,9 @@ def logins():
logging.info("response.text :%s" % response.text) logging.info("response.text :%s" % response.text)
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -178,7 +180,9 @@ if __name__ == "__main__": ...@@ -178,7 +180,9 @@ if __name__ == "__main__":
cookies = logins() cookies = logins()
click(cookies, id) if cookies is not None:
click(cookies, id)
# time.sleep(random.randint(500, 1000)) # time.sleep(random.randint(500, 1000))
...@@ -196,7 +200,9 @@ if __name__ == "__main__": ...@@ -196,7 +200,9 @@ if __name__ == "__main__":
cookies = logins() cookies = logins()
follow(cookies,id) if cookies is not None:
follow(cookies,id)
# time.sleep(random.randint(500, 1000)) # time.sleep(random.randint(500, 1000))
......
...@@ -71,7 +71,9 @@ def logins(): ...@@ -71,7 +71,9 @@ def logins():
logging.info("response.text :%s" % response.text) logging.info("response.text :%s" % response.text)
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -145,7 +147,9 @@ if __name__ == "__main__": ...@@ -145,7 +147,9 @@ if __name__ == "__main__":
cookies = logins() cookies = logins()
Urge(cookies, id) if cookies is not None:
Urge(cookies, id)
# time.sleep(random.randint(500, 1000)) # time.sleep(random.randint(500, 1000))
......
...@@ -71,7 +71,9 @@ def logins(): ...@@ -71,7 +71,9 @@ def logins():
logging.info("response.text :%s" % response.text) logging.info("response.text :%s" % response.text)
return {'sessionid': cook} if cook is not None:
return {'sessionid': cook}
except: except:
...@@ -138,7 +140,6 @@ def get_star_useid(numtime): ...@@ -138,7 +140,6 @@ def get_star_useid(numtime):
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return None
if __name__ == "__main__": if __name__ == "__main__":
try: try:
...@@ -162,7 +163,9 @@ if __name__ == "__main__": ...@@ -162,7 +163,9 @@ if __name__ == "__main__":
cookies=logins() cookies=logins()
Urge(cookies, id) if cookies is not None:
Urge(cookies, id)
# time.sleep(random.randint(500, 1000)) # time.sleep(random.randint(500, 1000))
...@@ -183,7 +186,9 @@ if __name__ == "__main__": ...@@ -183,7 +186,9 @@ if __name__ == "__main__":
cookies = logins() cookies = logins()
Urge(cookies, id) if cookies is not None:
Urge(cookies, id)
# time.sleep(random.randint(500, 1000)) # time.sleep(random.randint(500, 1000))
......
...@@ -62,7 +62,9 @@ def logins(): ...@@ -62,7 +62,9 @@ def logins():
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) logging.info("response.text :%s" % response.text)
return {'sessionid': cook}
if cook is not None:
return {'sessionid': cook}
except: except:
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
return None return None
...@@ -125,11 +127,12 @@ if __name__ == "__main__": ...@@ -125,11 +127,12 @@ if __name__ == "__main__":
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()
cook = logins() cook = logins()
pick(cook, id) if cook is not None:
pick(cook, id)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
......
import requests
import time
import datetime
import pymysql
import random
import traceback
# from log_settings import *
import logging
auto_pick_url = "http://172.30.8.42:9001/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(','))
# time.sleep(random.randint(0, 500))
maj = random.randint(1,len(list))
user_id=list[maj-1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def login():
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]
if cook is not None:
logging.info("response.text :%s" % response.text)
print({'sessionid': cook})
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def logins(id):
try:
cookies = index_first()
post_dict={
'account_type':2,
'pwd':'123456',
'email':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)
cok ={'sessionid': cook}
print(cok)
if cok is not None:
return cok
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def pick(cookies_get,id):
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)
print(response.text)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
print(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(id) FROM picktopic 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_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()
cursor.execute(
"select user_id from account_user WHERE is_online =1 and create_time LIKE '%%%%%s%%%%'" % numtime)
data_new_user = cursor.fetchall()
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)
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]
#topic
for i in range(len(time_list)):
numtime = time_conv(time_list[i])
# user_id = get_data(numtime)
user_id=[1,2,3]
for j in user_id:
# time.sleep(random.randint(200,500))
pick_num = random.randint(1, 2)
for i in range(pick_num):
cookies=login()
if cookies is not None:
pick(cookies, j)
# time.sleep(random.randint(500, 1000))
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
for i in range(3):
print(i)
for i in range(3):
print(i)
for i in range(3):
print(i)
\ No newline at end of file
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