import requests
import glob
import os
from concurrent.futures import ThreadPoolExecutor
files = 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)
.jpg)
文章《小旋风蜘蛛池pro版本文章入库python代码(qq好友提供)》于 2023年7月16日 发布在 新程序,如无特别说明文章均为原创,请勿采集、转载、复制。
相关文章
定时自动访问功能
可设置并发数量、是否使用代理、访问间隔 import random import re import threading import time import requests import string def gener …
关键词(文本)只在汉字间添加空格
import os import re # 定义函数,处理关键词文件 def process_keywords(file_path): with open(file_path, 'r', encoding='utf-8') as f: k …
关键词(文本)增加空格
import os # 定义函数,处理关键词文件 def process_keywords(file_path): with open(file_path, 'r', encoding='utf-8') as f: keywords = …
某度使用cookie直接登录的代码
进入百度贴吧界面,按F12,呼出下方界面,选择Console选项,然后在下面粘贴登录代码,回车,再刷新界面,就登录成功了! javascript:documen …
神马获取Authkey按钮提交成功方法(来自于网友)
Authkey无法获取的可以在页面<head>下插入 <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> …