|
#登录发帖
import requests,re
index_url = 'http://47.107.178.45/phpwind/'
s = requests.session()
# 1、首页
response = s.get(url=index_url)
token = re.findall('name="csrf_token" value="(.+?)"/>',response.text)[0]
print(token)
# 2、登录
login_url = 'http://47.107.178.45/phpwind/index.php'
params1 = {"m":"u","c":"login","a":"dologin"}
body_data = {"username":"cssj3","password":"123456","csrf_token":token}
response2 = s.post(url=login_url,data=body_data,params=params1)
statu = re.findall('statu=(.+?)">',response2.content.decode('utf-8'))[0]
print(statu)
# 3、登录2
login_url2 = 'http://47.107.178.45/phpwind/index.php?m=u&c=login&a=welcome&_statu=%s'%statu
res = s.get(url=login_url2)
# 4、发帖
fatie = 'http://47.107.178.45/phpwind/index.php?c=post&a=doadd&_json=1&fid=12'
body_data = {"atc_title":"resquests发帖1",
"atc_content":"很开心",
"pid":None,
"tid":None,
"special":"default",
"reply_notice":1,
"csrf_token":token}
s.post(url=fatie,data=body_data)
|
|