猫史档案馆


【Python作品分享】新的作品【教程贴】

用户:鲨鲨QWQ鲨鲨QWQ查看:0 回复:0 评论:0 创建时间:2023-01-12T21:26:27


【作品展示】

center_image

 

【作品介绍】

 

【作品源代码】

import requests as r
import json
import time
import os
from bs4 import BeautifulSoup
from json import loads, dumps

while True:
    zh = str(input("输入你的账号"))
    mm = str(input("输入你的密码"))
    fxses = r.session()
    fxheaders = {"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"}
    fxsoup = BeautifulSoup(r.get(
        'https://shequ.codemao.cn', headers=fxheaders).text, 'html.parser')
    fxpid = loads(fxsoup.find_all("script")[0].string.split("=")[1])['pid']
    fxa = fxses.post('https://api.codemao.cn/tiger/v3/web/accounts/login',
                     headers=fxheaders, data=dumps({"identity": zh, "password": mm, "pid": fxpid}))
    if fxa.status_code == 200:
        fxc = fxa.cookies
        fxcookies = r.utils.dict_from_cookiejar(fxc)
        fxcookiess = 'authorization=' + \
            fxcookies['authorization'] + ';acw_tc=' + fxcookies['acw_tc']
    else:
        print("不能登录编程猫")
    sj = r.get(
        "https://api.codemao.cn/creation-tools/v1/pc/discover/newest-work?offset=0&limit=100")
    sj = sj.text
    sj = json.loads(sj)
    for i in range(100):
        header = {"cookie": fxcookiess}
        date = {emoji_content: "编程猫_加油", content: "【自动】作品针不错,给你点赞啦"}
        r.post("https://api.codemao.cn/nemo/v2/works/%d/like" %
               sj['items'][i]['work_id'], headers=header)
        print("https://shequ.codemao.cn/work/%d" % sj['items'][i]['work_id'])
        r.post("https://api.codemao.cn/creation-tools/v1/works/%d/comment" %
               sj['items'][i]['work_id'], headers=header, date=date)
        time.sleep(5)
        print(sj['items'][i]['work_id'])
    time.sleep(3600)

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页