python 之 乐愚社区 自动顶贴 精简版 |
|
天灵灵
L0
• 2020-02-18 • 回复 5 • 最后编辑于2020-02-18 23:16 • 只看楼主
• 举报
|
import requests,time
from bs4 import BeautifulSoup
def start(q,w,e):
url='https://bbs.leyuxyz.com/verify'
url_1 = 'https://bbs.leyuxyz.com/post'
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36x-requested-with: XMLHttpRequest'}
data={'username': q,
'pwd': w,
'type': 'signin'}
session = requests.session()
session.post(url,headers=headers,data=data)
res=session.get('https://bbs.leyuxyz.com/member/这里写自己的昵称')
bs=BeautifulSoup(res.text,'html.parser')
id=bs.find_all(class_="tag-title")
a=[]
for i in id:
id_1 = int(i['href'][-6:])
a.append(id_1)
sum_1=1
for u in sorted(a):
data_1 = {'bid': ' 7',
'tid': u,
'type': 'reply',
'content': e,
'dataType': 'text'}
s1=session.post(url_1,headers=headers,data=data_1)
print(s1.status_code)
print('第%s帖完成'%sum_1)
sum_1+=1
print('等待12秒后继续顶贴')
time.sleep(12)
print('全部完成')
if __name__ == "__main__":
q = str(input('输入用户名'))
w = str(input('输入密码'))
e = str(input('输入顶贴内容'))
start(q, w, e)
纯属娱乐,如有冒犯,请删帖就好~~~~