使用易优CMS_Eyoucms火车头免登陆发布接口发布内容后在前端找不到文章,怎么办?
更新首页get请求:
http://你的域名/index.php?m=home&c=Buildhtml&a=buildIndexAll&lang=cn
更新文章页html 发送post请求:
http://你的域名/index.php?m=home&c=Buildhtml&a=upHtml&lang=cn
post数据内容:
{ 'aid': aid, 'typeid': typeid, 'type': 'view', 'ctl_name': 'Article', '_ajax': 1, }
更新列表页html 发送post请求:
http://你的域名/index.php?m=home&c=Buildhtml&a=upHtml&lang=cn
post 数据内容:
{ 'aid': aid, 'typeid': typeid, 'type': 'lists', 'ctl_name': 'Article', '_ajax': 1, }
我的文章发布工具Python:
import urllib.request import urllib.parse import json def eyoucms_post(title, content, typeid, channel, domain, _password): headers = { "User-Agent" : "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.6) ", "Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language" : "zh-cn", "Connection" : "keep-alive", } url = "http://" + domain + "/api/publishArticle/insertArchives?__post_flag=post" data_form = { "__post_password": _password, "typeid": typeid, # 栏目ID,取得方法:后台管理->栏目管理->ID列的数字 "channel": channel, # 频道模型,取得方法:后台管理->高级选项->频道模型->取得“文章模型”的ID "title": title, "content": content, } data = urllib.parse.urlencode(data_form).encode(encoding='utf-8') req = urllib.request.Request(url, data=data, headers=headers) res = urllib.request.urlopen(req, timeout=60) result = res.read().decode('utf-8') # 解析JSON json_data = json.loads(result) if "data" in json_data and "url" in json_data["data"]: parsed_url = urllib.parse.urlparse(json_data["data"]["url"]) query_params = urllib.parse.parse_qs(parsed_url.query) aid_value = query_params.get("aid", [""])[0] return aid_value return None # 若未找到aid,则返回None def upindex(domain): headers = { "User-Agent" : "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.6) ", "Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language" : "zh-cn", "Connection" : "keep-alive", } url = "http://" + domain + "/index.php?m=home&c=Buildhtml&a=buildIndexAll&lang=cn" data_form = { } data = urllib.parse.urlencode(data_form).encode(encoding='utf-8') req = urllib.request.Request(url, data=data, headers=headers) res = urllib.request.urlopen(req, timeout=60) result = res.read().decode('utf-8') return result def upview(domain, aid, typeid): headers = { "User-Agent" : "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.6) ", "Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language" : "zh-cn", "Connection" : "keep-alive", } url = "http://" + domain + "/index.php?m=home&c=Buildhtml&a=upHtml&lang=cn" data_form = { 'aid': aid, 'typeid': typeid, 'type': 'view', 'ctl_name': 'Article', '_ajax': 1, } data = urllib.parse.urlencode(data_form).encode(encoding='utf-8') req = urllib.request.Request(url, data=data, headers=headers) res = urllib.request.urlopen(req, timeout=60) result = res.read().decode('utf-8') return result def uplists(domain, aid, typeid): headers = { "User-Agent" : "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.6) ", "Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language" : "zh-cn", "Connection" : "keep-alive", } url = "http://" + domain + "/index.php?m=home&c=Buildhtml&a=upHtml&lang=cn" data_form = { 'aid': aid, 'typeid': typeid, 'type': 'lists', 'ctl_name': 'Article', '_ajax': 1, } data = urllib.parse.urlencode(data_form).encode(encoding='utf-8') req = urllib.request.Request(url, data=data, headers=headers) res = urllib.request.urlopen(req, timeout=60) result = res.read().decode('utf-8') return result if __name__ == "__main__": title = "这是python自动发布的文章" content = "这是python自动发布的文章内容" typeid = 14 channel = 1 domain = "我的域名" _password = "这个和发布接口的密码一致" aid = eyoucms_post(title, content, typeid, channel, domain, _password) print(aid) upindex(domain) print(upview(domain, aid, typeid)) print(uplists(domain, aid, typeid))