伪原创api(批量处理代码worker.py)
优采云 发布时间: 2021-09-22 09:06伪原创api(批量处理代码worker.py)
最近,公司必须处理一批文章,所以写一个批处理工具,这个伪原创效果非常满意,它非常有帮助收录,你可以尝试它,代码python写道。
文章进程,文章
import requests
from requests.structures import CaseInsensitiveDict
url = "http://api.xiaofamao.com/api.php?json=0&v=1&key=testkey"
headers = CaseInsensitiveDict()
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/x-www-form-urlencoded"
data = "wenzhang=%E5%BA%8A%E5%89%8D%E6%98%8E%E6%9C%88%E5%85%89%EF%BC%8C%E7%96%91%E6%98%AF%E5%9C%B0%E4%B8%8A%E9%9C%9C%E3%80%82"
resp = requests.post(url, headers=headers, data=data)
print(resp.status_code)
批处理代码worker.py:
def run(self):
make_sure_dir_exists(self.target_dir) # 确保目录存在
source_dir = self.filename
# 计数器
flag = 0
# 文件名
name = 1
# 存放数据
dataList = []
final_data = ''
self.sendMessage("set_info", self.file_name(source_dir))
self.sendMessage("set_info", datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
self.sendMessage("set_info", "开始伪原创")
# open(filename, "r", encoding='utf-8')
f_charInfo = ''
with open(source_dir, 'rb') as f:
data = f.read()
f_charInfo = chardet.detect(data)
if 'utf-8' not in f_charInfo['encoding'].lower():
self.sendMessage("set_info", '错误:文件非utf-8编码,暂不支持'+f_charInfo['encoding'])
return
#print(f_charInfo)
final_data = ''
temp_str = ''
final_str = ''
fail_str = ''
with open(source_dir, 'r', encoding='utf-8') as f_source:
for line in f_source:
one_title = line.strip()
#one_article = self.get_ai_articlev2(one_title)
one_article = self.get_ai_articlev2(one_title)
one_article = self.content_filter(one_article) # 过滤关键词
new_title = self.get_rand_title()
new_title = one_title+new_title
if len(one_article) > 10:
file_name_short = self.remove_bad_file_symble(new_title)
file_name = self.target_dir + '/'+file_name_short + '.txt'
with open(file_name, "w", encoding="utf-8") as f:
ret_val = f.write(one_article)
else:
print(one_article)
self.sendMessage("set_info", '正在写作,标题:'+new_title)
time.sleep(2)
选择合适的材料后,您已进入伪原创的步骤。此时,您需要提取文章和几个核心零件或视图的中心思想.Haha,当您看时,感觉就像阅读理解一样,把文章分节,总结段想法。
是的,它是对的,它相当于简化和精制文章的核心元素。在此过程中,关键词也可以选择性地改进,这是表达文章思想的必要核心材料。
实际上,普通人的阅读能力不是大的。擅长,这个阶段是从原创内容中提取的,以形成伪原创的轮廓。