Commit ac9b4918 authored by 李小芳's avatar 李小芳

modify

parent 4981af62
import requests
import time
import datetime
import pymysql
cookies = {
"sessionid": '1',
}
#login click
auto_click_url = "http://earth.igengmei.com/api/v1/like"
login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first():#抽取需要get的cookies
r1=requests.get(login_url)
return r1.cookies.get_dict()
def login(cookies,user,pwd):
post_dict={#登录时要提交的数据
'account_type':user,
'pwd':pwd
}
response=requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
print(response.text,'url')
def dz(cookies_get,id):
post_dict={
'type':0,
'id':id
}
response=requests.post(url=auto_click_url,
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
def time_conv(numtime):
now = datetime.datetime.now()
three_days_later = now -datetime.timedelta(days=numtime)
print(three_days_later)
print(now())
return numtime
def get_data(numtime):
# 打开数据库连接
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db="alpha", port=3306)
# 使用cursor()方法获取操作游标
cursor = db.cursor()
# 使用execute方法执行SQL语句
cursor.execute("select id from topic where is_online=0 and create_time ={}".format(numtime))
# 使用 fetchone() 方法获取一条数据
data = cursor.fetchall()
user_id = list(data)
print("Database version : %s " % user_id)
# 关闭数据库连接
db.close()
return user_id
time_list=[1,3,5,7,15,21,28,35]
for i in time_list:
numtime=time_conv(i)
user_id=get_data(numtime)
for i in user_id:
cookies=index_first()
login(cookies,user=cookies,pwd='')
dz(cookies,i)
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