请选择 进入手机版 | 继续访问电脑版

湖南新梦想

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 609|回复: 0

requests实现phpwind论坛J接口发帖

[复制链接]

23

主题

23

帖子

168

积分

注册会员

Rank: 2

积分
168
发表于 2023-1-6 18:41:21 | 显示全部楼层 |阅读模式
#登录发帖
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)

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|湖南新梦想 ( 湘ICP备18019834号-2 )

GMT+8, 2023-10-4 13:32 , Processed in 0.042388 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表