用户:我叫以赏查看:41 回复:57 评论:41 创建时间:2020-05-31T20:43:36
本文章没有迎战,仅供参考,此文章为我的上文章重投版
对于月休党来说,回家的两天实在是搞不出什么大事情,在家里闲的很,不知我在整理我的收藏夹以及网盘文件的时候,我突然想起来,不是还有一个“编程喵坛”吗?那么编程猫主打的是Python,论坛的防护机制做的也不是很好,那我用Python爬虫去爬取论坛的网页数据应该是情有可原的吧?
随意打开一个帖子开始抓包,我先拿爬取编程喵坛的帖子数。
不错这句是获取帖子信息的请求,分析接口,使用GET方式,加上帖子ID就可以获取帖子的信息了。
当没有此帖子的时候就会返回404。
那么编程猫最早的帖子是什么呢?
由图可知,编程猫最早的帖子ID为54号。网址:
https://shequ.codemao.cn/community/54
找一个最近的帖子,
出现的“断崖层”,看来截止目前为止帖子数最多到304265。
我们来做一个新帖自动回复,找一个自己的帖子
测试一下,
这个就不可以简单的调用了,总之通过以上的调用方法可以正常发送一条评论,现在只要循环遍历每一个文章就行了。
开始!
哦,这个机制是防止狂刷,那么我们等待5秒。
我可不想被封号,那就到这里吧。
现在来做做自动点赞。
同样的抓包,
中间的数字应该就是评论ID了,与文章不同,
找了半天终于找到了,现在开始写代码。。。。
结果是第一层全点赞了,若要把回评论需要进一步分析,我本来就图个乐何为呢?
(下期 编程猫刷浏览量)
编程喵坛还有一个特性,每当评论时你的文章总会置顶,知道怎么利用了吗?
蒟蒻OIer1048576import requests
from json import dumps, loads
from bs4 import BeautifulSoup
class codemaoAPI(object):
def __init__(self, identity, password,
UA='Mozilla/5.0 (Windows NT 10.0; ) AppleWebKit/537.36 (KH喵L, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
debug=False):
self.debug = debug
self.ses = requests.session()
self.headers = {"Content-Type": "application/json", "User-Agent": UA}
self.log('getting pid...')
soup = BeautifulSoup(requests.get('https://shequ.codemao.cn', headers = self.headers).text, 'html.parser')
pid = loads(soup.find_all("script")[0].string.split("=")[1])['pid']
self.log('Successfully get pid;pid=' + pid)
self.log('loginning...')
a = self.ses.post('https://api.codemao.cn/tiger/v3/web/accounts/login', headers = self.headers,
data = dumps({"identity": identity, "password": password, "pid": pid}))
if a.status_code == 200:
self.log("Successfully login to codemao.cn")
else:
self.log('End of login to codemao.cn;response', a.status_code)
def log(self, *msg):
if self.debug:
print(*msg)
def send_post(self, board, title, message):
self.log('posting...')
a = self.ses.post(f'https://api.codemao.cn/web/forums/boards/{board}/posts', headers = self.headers,
data = dumps({'title': title, 'content': message}))
self.log('End.response', a.status_code)
def replies(self, postID, message):
self.log('replieing...')
a = self.ses.post(f'https://api.codemao.cn/web/forums/posts/{postID}/replies', headers = self.headers,
data = dumps({'content': message}))
self.log('End.response', a.status_code)
def __delete_work(self, workID): # BUG
self.log('deleting...')
a = self.ses.delete(f'https://api.codemao.cn/tiger/work/{workID}/temporarily', headers = self.headers)
self.log('End.response', a.status_code)
def __recove_work(self, workID): # BUG
self.log('recoving...')
a = self.ses.patch(f'https://api.codemao.cn/tiger/work/{workID}/recover', headers = self.headers)
self.log('End.response', a.status_code)
def __permanent_work(self, workID): # BUG
self.log('permanenting...')
a = self.ses.delete(f'https://api.codemao.cn/tiger/work/{workID}/permanently', headers = self.headers)
self.log('End.response', a.status_code)
def delete_all_work(self):
self.log('All work are permanenting...')
a = self.ses.delete('https://api.codemao.cn/tiger/work/user/works/permanently', headers = self.headers)
self.log('End.response', a.status_code)
def send_post_to_work_shop(self, work_shop_ID, message):
self.log('posting...')
a = self.ses.post(f'https://api.codemao.cn/web/discussions/{work_shop_ID}/comment', headers = self.headers,
data = dumps({"content": message, "rich_content": message, "source": "WORK_SHOP"}))
self.log('End.response', a.status_code)
def top_replies(self, repliesID):
self.log('On top...')
a = self.ses.put(f'https://api.codemao.cn/web/forums/replies/{repliesID}/top', headers = self.headers,
data = r'{}')
self.log('End.response', a.status_code)
def untop_replies(self, repliesID):
self.log('Untop...')
a = self.ses.delete(f'https://api.codemao.cn/web/forums/replies/{repliesID}/top', headers = self.headers)
self.log('End.response', a.status_code)
def like_replies(self, repliesID):
self.log('liking...')
self.ses.put(f'https://api.codemao.cn/web/forums/comments/{repliesID}/liked?source=REPLY',
headers = self.headers, data = r'{}')
self.log('End.response', a.status_code)
def unlike_replies(self, repliesID):
self.log('Unliking...')
self.ses.delete(f'https://api.codemao.cn/web/forums/comments/{repliesID}/liked?source=REPLY',
headers = self.headers)
点赞0
评论
公布我的超高速刷浏览工具代码嗷:
import aiohttp,asyncio
from threading import Thread
times=1
headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; ) AppleWebKit/537.36 (KHT"+"ML, like Gecko) Chrome/81.0.4044.92 Safari/537.36"}
async def visit(pid):
global times
for x in range(5):
async with aiohttp.ClientSession() as session:
async with session.get("https://api.codemao.cn/web/forums/posts/"+pid+"/details") as resp:
print(times,":visit ",pid,"\tstatus ",resp.status,sep="")
times+=1
def start(pid):
new_loop = asyncio.new_event_loop()
asyncio.set_event_loop(new_loop)
loop=asyncio.get_event_loop()
loop.run_until_complete(asyncio.gather(visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid),visit(pid)))
def themain_(pid):
for x in range(5):
threads=[Thread(target=start,args=(pid,)) for x in range(5)]
for t in threads:
t.setDaemon(True)
t.start()
for t in threads:
t.join()
def main_(pid):
for x in range(5):
threads=[Thread(target=themain_,args=(pid,)) for x in range(5)]
for t in threads:
t.setDaemon(True)
t.start()
for t in threads:
t.join()
main_(帖子ID)点赞0
评论
蒟蒻OIer1048576GUIMaker文档
menu
GUIMaker | 文档
GuiMaker介绍
GuiMaker的GUI类
GuiMaker介绍
guimaker由1048576,未入门的程序员和Toby共同开发,是一个基于tkinter的简易、轻量级的Python gui。使用它,您可以轻松的写出一个GUI程序。
__init__(self, width=300, height=300, title="Window") width: 宽度 text(self, text="", x=None, y=None, color="black", var=None) text:要显示的文本 button(command, width=20, height=20, text="", x=None, y=None, var=None) text:要显示的文本 run() 使用guimaker必须有且在最后调用run方法点赞0
评论