标签: pytumblr

打印来自Tumblr API的20多个帖子

下午好,

我是Python的新手,但我正在尝试编写一个代码,允许我从指定的Tumblr帐户下载所有帖子(包括"笔记")到我的电脑.

鉴于我没有编码经验,我试图找到一个预制的脚本,这将允许我这样做.我在GitHub上找到了几个精彩的脚本,但是没有一个真正从Tumblr帖子中返回笔记(据我所见,尽管如果有人知道那个,那么请纠正我!).

因此,我试着编写自己的脚本.我在下面的代码中取得了一些成功.它打印出来自给定Tumblr的最新20个帖子(尽管格式相当丑陋 - 基本上数百行文本都打印在记事本文件的一行中):

#This script prints all the posts (including tags, comments) and also the 
#first 20notes from all the Tumblr blogs.

import pytumblr

# Authenticate via API Key
client = pytumblr.TumblrRestClient('myapikey')

#offset = 0

# Make the request
client.posts('staff', limit=2000, offset=0, reblog_info=True, notes_info=True, 
filter='html')
#print out into a .txt file
with open('out.txt', 'w') as f:
print >> f, client.posts('staff', limit=2000, offset=0, reblog_info=True, 
notes_info=True, filter='html')
Run Code Online (Sandbox Code Playgroud)

但是,我希望脚本能够连续打印帖子,直到它到达指定博客的末尾.

我搜索了这个网站,发现了一个非常相似的问题(只通过PyTumblr返回了20个帖子),这已经被stackoverflow用户戳回答了.但是,我似乎无法实际实现poke的解决方案,以便它适用于我的数据.实际上,当我运行以下脚本时,根本不会产生任何输出.

import pytumblr

# Authenticate via API Key
client …
Run Code Online (Sandbox Code Playgroud)

python tumblr pytumblr

6
推荐指数
1
解决办法
871
查看次数

标签 统计

python ×1

pytumblr ×1

tumblr ×1