python:帝国cms已发布文章敏感词检测替换(含未审核文章检测)

python:帝国cms已发布文章敏感词检测替换(含未审核文章检测)

python:帝国cms已发布文章敏感词检测替换(含未审核文章检测)-源码网
python:帝国cms已发布文章敏感词检测替换(含未审核文章检测)
此内容为付费阅读,请付费后查看
168
立即购买
您当前未登录!建议登陆后购买,可保存购买订单
付费阅读

2323

python:帝国cms已发布文章敏感词检测替换,用百度ai文件敏感词检测接口,源码已经做了整合,包含了已发布和未审核检测,一键自动替换数据库文章字段内容。如果你的网站长期不收录,可以检测一下敏感词,正常运营收录的网站,也要经常检测敏感词和违规。以上8个检测,打包价568元。

部分代码演示:

sql = cursor.execute("SELECT id, newstext FROM phome_ecms_news_data_1 WHERE ischeck = 0  order by rand() limit 1 ")
if sql == 0:
print("检测完毕!")
break
articles = cursor.fetchone()
articles = list(articles)
ids = articles[0] # 文章id
content = articles[1] # 文章内容
spam = baidu_ai_sensitive_word_detection(content)
if not spam:
print(f"ID:{ids} 的文章合规")
cursor.execute("UPDATE phome_ecms_news_data_1 SET ischeck = 1 WHERE id=%s ", ids)
else:
print(f"ID:{ids} 的文章不合规")
keyword = spam[1]
content = content.replace(keyword, '***')
cursor.execute("UPDATE phome_ecms_news_data_1 SET newstext = %s WHERE id = %s and ischeck = 0",(content, ids))
print(spam[0] + ":替换【" + spam[1] + "】,为***")
cursor.execute("UPDATE phome_ecms_news_data_1 SET ischeck = 1 WHERE id=%s ", ids)
conn.commit()
#time.sleep(1) # Wait 10 minutes before checking the database again

完整代码如下:

© 版权声明
THE END
喜欢就支持一下吧
点赞5 分享