我正在创建一个简单的 python 脚本,它使用 xmlrpc API 检查 WordPress 博客上的新评论。
我陷入了一个循环,该循环应该告诉我是否有新评论。这是代码:
def checkComm():
old_commCount = 0;
server = xmlrpclib.ServerProxy(server_uri); # connect to WP server
comments = server.wp.getComments(blog_id, server_admin, admin_pass, filters);
new_commCount = len(comments);
if new_commCount > old_commCount:
print "there are new comments"
old_commCount = new_commCount
else:
print "no new comments"
while True:
checkComm()
time.sleep(60)
我跳过了 blog_id、server_admin 等变量,因为它们对这个问题没有任何帮助。
你能告诉我的代码有什么问题吗?
提前非常感谢。