用户:
蒟蒻OIer1048576查看:7 回复:5 评论:7 创建时间:2020-06-03T08:48:20
import requests
from bs4 import BeautifulSoup
from json import loads,dumps
ses = requests.session()
headers = {"Content-Type": "application/json", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; ) AppleWebKit/537.36 (KH喵L, like Gecko) Chrome/81.0.4044.138 Safari/537.36"}
print('正在寻找登录密钥...')
soup = BeautifulSoup(requests.get('https://shequ.codemao.cn', headers = headers).text, 'html.parser')
pid = loads(soup.find_all("script")[0].string.split("=")[1])['pid']
print('秘药为:',pid)
print('正在登录')
a = ses.post('https://api.codemao.cn/tiger/v3/web/accounts/login', headers = headers,
data = dumps({"identity": "你的手机号", "password": "你的密码", "pid": pid}))
if a.status_code == 200:
print("登录成功")
else:
exit("不能登录编程猫")
print('正在顶帖')
postID = int(input("请输入顶贴id - >>>"))
a = ses.post(f'https://api.codemao.cn/web/forums/posts/{postID}/replies', headers = headers,
data = dumps({'content': "<p>dd</p>"}))
print("成功" if a.status_code == 201 else "失败")