[ol]import requestsimport globimport osfrom concurrent.futures import ThreadPoolExecutorfiles = glob.glob('./文章/*.txt')HEADERS = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.139 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",}def postxxf(f): with open(f,"rb") as fd: content = fd.read().decode("utf-8") title = os.path.basename(f).split(".")[0] try: rsp = requests.post("你的小旋风发布接口", timeout=30, headers=HEADERS, data={"title": title, "body": content}) print("正在发布:", title) print(rsp.json()["msg"]) except Exception as e: print("小旋风发布出错", e)if __name__ == "__main__": published_titles = set() publish_count = 0 with ThreadPoolExecutor(max_workers=20) as tdp: for f in files: title = os.path.basename(f).split(".")[0] if title in published_titles: print("已发布:", title) continue tdp.submit(postxxf, f) published_titles.add(title) publish_count += 1 tdp.shutdown(wait=True) print("发布总数:", publish_count)[/ol]复制代码原文地址:https://xinchengxu.com/code/33998.html 由qq好友提供,方便把本地文章灌入pro版本的小旋风 小旋风, 文章