编程语言
首页 > 编程语言> > 如何使用python / tumblr api从帖子中获取备注信息?

如何使用python / tumblr api从帖子中获取备注信息?

作者:互联网

我对所有这些级别的问题感到困惑,我不得不通过刮痧来解决这个问题,但是我想这是一个很好的练习来学习dicts,并且一旦我弄明白就会更快.

我的代码如下,其中cposts的赋值语句返回404:

import pytumblr

# Authenticate via OAuth
client = pytumblr.TumblrRestClient(
    'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
)

f = client.followers('blog.tumblr.com')

users = f['users']

names = [b['name'] for b in f['users']]
print names

cposts = client.posts(names[0], 'notes_info=True')

print (cposts)

但是python api信息说:client.posts(‘codingjester’,** params)#获取博客的帖子

这个SO帖子(Getting more than 50 notes with Tumblr API)说你应该使用notes_info来获取笔记.但我不知道如何在python中构建它而不是制作一个url.

我可以使用构建URL的请求,但我认为有一种更简单的方法使用python / tumblr api我只是没有想出来,如果有人能照亮请.

解决方法:

删除notes_info = True周围的引号.您应该将值True传递给客户端的posts()方法的notes_info参数.相反,您实际上是将字符串’notes_info = True’作为位置参数传递,这是无效的并导致pytumblr创建无效的URL,这就是您获得404的原因.

标签:python,tumblr,api
来源: https://codeday.me/bug/20190706/1397943.html