【发布时间】:2018-12-20 07:28:35
【问题描述】:
我正在尝试使用模块 python-wordpress-xmlrpc 来编辑我的帖子标题。但最后一行出错。不知道“EditPost”的用法。有人可以举例说明吗?
#find allpost 'movie'
allpost = client.call(posts.GetPosts({'post_type':'movie'}))
#find post title 'Bumblebee' n change 'Bumblebee 2018'
for post in allpost:
if post.title =='Bumblebee':
post.title = 'Bumblebee 2018'
client.call(posts.EditPost(post.id, post))
错误:
Traceback (most recent call last):
File "D:\Movie Website\remote upload\post.py", line 28, in <module>
wp.call(EditPost(post.id,post))
File "C:\Python27\lib\site-packages\wordpress_xmlrpc\base.py", line 37,
in call
raw_result = server_method(*args)
File "C:\Python27\lib\xmlrpclib.py", line 1243, in __call__
return self.__send(self.__name, args)
File "C:\Python27\lib\xmlrpclib.py", line 1602, in __request
verbose=self.__verbose
File "C:\Python27\lib\xmlrpclib.py", line 1283, in request
return self.single_request(host, handler, request_body, verbose)
File "C:\Python27\lib\xmlrpclib.py", line 1316, in single_request
return self.parse_response(response)
File "C:\Python27\lib\xmlrpclib.py", line 1493, in parse_response
return u.close()
File "C:\Python27\lib\xmlrpclib.py", line 800, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 404: 'Invalid attachment ID.'>
【问题讨论】:
-
您能否重新格式化问题以便正确查看代码?还包括错误。
-
好的..完成编辑..希望你能解决我的问题
-
"但最后一行的错误"是对您的问题的基本无用描述。请发布 eact 错误消息和完整的回溯。
-
我忘了添加..添加错误..
-
查看this issue,似乎
GetPosts获得的帖子比EditPost中预期的帖子拥有更多数据。我没有自己测试的环境。试试看它是否有效。
标签: python wordpress python-2.7 xmlrpcclient