python发布文章到帝国cms
可以使用火车头发布接口进行post
下载火车头发布接口文件jiekou_utf8.php:
选择您网站对应的接口文件.如您网站是gbk编码,请选择 jiekou_gbk.php. 如果是UTF-8编码,请选择jiekou_utf8.php
打开接口文件,修改验证密码,第十行左右,然后保存.
修改接口文件名并上传至网站的管理目录/e/admin/ 目录下
帝国CMS免登录文章发布接口文件下载地址:http://faq.locoy.com/q-1289.html
下面利用python进行post示例:
#!/usr/bin/env python3 # -*- coding:utf-8 -*- import time from turtle import title import urllib.request import urllib.parse def post(title, content): query = "https://www.360baiduseo.com/e/admin/jiekou_utf8.php?pw=123456" # 接口文件第十行中的验证密码一致 data_form = { "enews": "AddNews", "classid": 1, # 栏目id "bclassid": 0, # 父栏目id "id": 0, "filepass": int(time.time()), # 发布文章的时间戳 "username": "admin", # 后台用户名 "oldchecked": 1, "ecmsnfrom": 1, "ecmscheck": 0, "havetmpic": 0, "title": title, "checked": 0, # 0待审核 1为发布 "isgood": 0, "firsttitle": 0, "newstime": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), "writer": "admin", "befrom": "", "newstext": content, "dokey": 1, "copyimg": 1, "autosize": 5000, "istop": 0, "newstempid": 0, "groupid": 0, "newspath":"", #栏目目录地址 "userfen": 0, "onclick": 0, "totaldown": 0, "addnews": "提 交", #若有自定义字段,也可在后面添加 } data = urllib.parse.urlencode(data_form).encode(encoding='utf-8') req = urllib.request.Request(query, data=data) res = urllib.request.urlopen(req, timeout=60) result = res.read().decode('utf-8') print(result)