Commit e5b7e34f authored by lixiaofang's avatar lixiaofang

cookies

parent 1ffd3535
This diff is collapsed.
......@@ -74,6 +74,10 @@ def login():
logging.info("response.text :%s"%response.text)
cok = {'sessionid': cook}
if cook is not None:
return {'sessionid': cook}
except:
......@@ -106,6 +110,8 @@ def logins(id):
logging.info("response.text :%s" % response.text)
if cook is not None:
return {'sessionid': cook}
except:
......@@ -243,6 +249,8 @@ if __name__ == "__main__":
cookies= login()
if cookies is not None:
comment = get_comment()
reply(cookies, id, comment)
......
......@@ -76,6 +76,8 @@ def login():
logging.info("response.text %s"%response.text)
if cook is not None:
return {'sessionid': cook}
except:
......@@ -161,6 +163,8 @@ if __name__ == "__main__":
cook=login()
if cook is not None:
click(cook, rand_id)
except:
......
......@@ -71,6 +71,8 @@ def logins():
logging.info("response.text : %s"%response.text)
if cook is not None:
return {'sessionid': cook}
except:
......@@ -158,6 +160,8 @@ if __name__ == "__main__":
cook=logins()
if cook is not None:
click(cook, rand_id)
except:
......
......@@ -21,7 +21,6 @@ def index_first():
return None
def get_majia():
try:
......@@ -73,6 +72,8 @@ def logins():
logging.info("response.text %s"%response.text)
if cook is not None:
return {'sessionid': cook}
except:
......@@ -86,7 +87,7 @@ def follow(cookies_get, id):
'type': 1,
'id': id
}
response = requests.post(url=auto_click_url,
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
......@@ -139,6 +140,8 @@ if __name__ == "__main__":
cook=logins()
if cook is not None:
follow(cook, id)
except:
......
......@@ -78,6 +78,8 @@ def logins():
cook = cook[0].split('=')[1]
if cook is not None:
return {'sessionid': cook}
except:
......
......@@ -22,7 +22,6 @@ def index_first():
return None
def get_majia():
try:
......@@ -74,6 +73,8 @@ def logins():
logging.info("response.text :%s" %response.text)
if cook is not None:
return {'sessionid': cook}
except:
......@@ -188,6 +189,8 @@ if __name__ == "__main__":
cookies=logins()
if cookies is not None:
follow(cookies, id)
......@@ -205,6 +208,8 @@ if __name__ == "__main__":
cookies = logins()
if cookies is not None:
pick(cookies, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
......@@ -71,6 +71,8 @@ def logins():
logging.info("response.text :%s"%response.text)
if cook is not None:
return {'sessionid': cook}
except:
......@@ -195,6 +197,8 @@ if __name__ == "__main__":
cookies=logins()
if cookies is not None:
follow(cookies, id)
# time.sleep(random.randint(2000,2500))
......
......@@ -71,6 +71,8 @@ def logins(user_id):
logging.info("response.text :%s" % response.text)
if cook is not None:
return {'sessionid': cook}
except:
......@@ -79,7 +81,6 @@ def logins(user_id):
return None
def follow(cookies_get, id):
try:
......@@ -97,7 +98,6 @@ def follow(cookies_get, id):
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv():
try:
now = datetime.datetime.now()
......@@ -105,6 +105,7 @@ def time_conv():
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',
......@@ -122,7 +123,6 @@ def get_follw_majia(numtime):
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
try:
......@@ -171,6 +171,8 @@ if __name__ == "__main__":
cookies=logins(id)
if cookies is not None:
follow(cookies,i)
except:
......
......@@ -71,6 +71,8 @@ def logins():
logging.info("response.text :%s"%response.text)
if cook is not None:
return {'sessionid': cook}
except:
......@@ -175,8 +177,11 @@ if __name__ == "__main__":
# time.sleep(random.randint(500, 1500))
for i in range(follow_num):
cookies = logins()
if cookies is not None:
follow(cookies, id)
# time.sleep(random.randint(2000, 3000))
......
......@@ -75,6 +75,8 @@ def logins():
logging.info("response.text :%s" % response.text)
if cook is not None:
return {'sessionid': cook}
except:
......@@ -158,10 +160,10 @@ if __name__ == "__main__":
for i in range(urge_num):
cookies = index_first()
cook=logins()
if cook is not None:
pick(cook, id)
follow(cook,id)
......
......@@ -104,7 +104,11 @@ def logins(id):
logging.info("response.text :%s" % response.text)
return {'sessionid': cook}
cok ={'sessionid': cook}
if cok is not None:
return cok
except:
......@@ -216,6 +220,8 @@ if __name__ == "__main__":
cookies=login()
if cookies is not None:
pick(cookies, id)
# time.sleep(random.randint(500, 1000))
......@@ -239,6 +245,8 @@ if __name__ == "__main__":
cookies = login()
if cookies is not None:
pick(cookies, id)
# time.sleep(random.randint(500, 1000))
......@@ -265,6 +273,8 @@ if __name__ == "__main__":
cookies = logins(id)
if cookies is not None:
pick(cookies, i)
except:
......
......@@ -72,6 +72,8 @@ def logins():
logging.info("response.text :%s" % response.text)
if cook is not None:
return {'sessionid': cook}
except:
......@@ -139,6 +141,8 @@ if __name__ == "__main__":
cook = logins()
if cook is not None:
Urge(cook, id)
except:
......
......@@ -71,6 +71,8 @@ def login():
logging.info("response.text :%s" % response.text)
if cook is not None:
return {'sessionid': cook}
except:
......@@ -104,6 +106,8 @@ def logins(id):
logging.info("response.text :%s" % response.text)
if cook is not None:
return {'sessionid': cook}
except:
......@@ -149,12 +153,12 @@ def get_data(numtime):
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)
......@@ -213,6 +217,8 @@ if __name__ == "__main__":
cookies = login()
if cookies is not None:
pick(cookies, id)
# time.sleep(random.randint(500, 1000))
......@@ -239,6 +245,8 @@ if __name__ == "__main__":
cookies = logins(id)
if cookies is not None:
pick(cookies, i)
except:
......
......@@ -74,6 +74,8 @@ def logins():
logging.info("response.text :%s" % response.text)
if cook is not None:
return {'sessionid': cook}
except:
......@@ -178,6 +180,8 @@ if __name__ == "__main__":
cookies = logins()
if cookies is not None:
click(cookies, id)
# time.sleep(random.randint(500, 1000))
......@@ -196,6 +200,8 @@ if __name__ == "__main__":
cookies = logins()
if cookies is not None:
follow(cookies,id)
# time.sleep(random.randint(500, 1000))
......
......@@ -71,6 +71,8 @@ def logins():
logging.info("response.text :%s" % response.text)
if cook is not None:
return {'sessionid': cook}
except:
......@@ -145,6 +147,8 @@ if __name__ == "__main__":
cookies = logins()
if cookies is not None:
Urge(cookies, id)
# time.sleep(random.randint(500, 1000))
......
......@@ -71,6 +71,8 @@ def logins():
logging.info("response.text :%s" % response.text)
if cook is not None:
return {'sessionid': cook}
except:
......@@ -138,7 +140,6 @@ def get_star_useid(numtime):
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
try:
......@@ -162,6 +163,8 @@ if __name__ == "__main__":
cookies=logins()
if cookies is not None:
Urge(cookies, id)
# time.sleep(random.randint(500, 1000))
......@@ -183,6 +186,8 @@ if __name__ == "__main__":
cookies = logins()
if cookies is not None:
Urge(cookies, id)
# time.sleep(random.randint(500, 1000))
......
......@@ -62,6 +62,8 @@ def logins():
cook = headers['Set-Cookie'].split(";")
cook = cook[0].split('=')[1]
logging.info("response.text :%s" % response.text)
if cook is not None:
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
......@@ -125,10 +127,11 @@ if __name__ == "__main__":
urge_num = random.randint(1, 2)
for i in range(urge_num):
cookies = index_first()
cook = logins()
if cook is not None:
pick(cook, id)
except:
......
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