from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.posts import GetPosts
from wordpress_xmlrpc import WordPressTerm
from wordpress_xmlrpc.methods import posts
client = Client('site/xmlrpc.php', 'user', 'pass')
data = []
offset = 0
increment = 20
while True:
wp_posts = client.call(posts.GetPosts({'number': increment, 'offset': offset}))
if len(wp_posts) == 0:
break # no more posts returned
for post in wp_posts:
print(post.title)
data.append(post.title)
offset = offset + increment
2条答案
按热度按时间cyvaqqii1#
我是这么做的:
qgzx9mmu2#
根据文档,您可以传递一个参数,指示您想要检索多少帖子:
第一个月
或者,如果你想得到所有的帖子,看看这个:https://python-wordpress-xmlrpc.readthedocs.org/en/latest/examples/posts.html#result-paging