【发布时间】:2016-11-15 20:37:19
【问题描述】:
关于 Soundcloud API 指南 (https://developers.soundcloud.com/docs/api/guide#pagination) 读取100多条数据的例子如下:
# get first 100 tracks
tracks = client.get('/tracks', order='created_at', limit=page_size)
for track in tracks:
print track.title
# start paging through results, 100 at a time
tracks = client.get('/tracks', order='created_at', limit=page_size,
linked_partitioning=1)
for track in tracks:
print track.title
我很确定这是错误的,因为我发现“tracks.collection”需要引用而不仅仅是“tracks”。根据 GitHub python soundcloud API wiki,它应该看起来更像这样:
tracks = client.get('/tracks', order='created_at',limit=10,linked_partitioning=1)
while tracks.collection != None:
for track in tracks.collection:
print(track.playback_count)
tracks = tracks.GetNextPartition()
我从最后一行删除了缩进(我认为 wiki 上有一个错误,它位于 for 循环中,这对我来说毫无意义)。这适用于第一个循环。但是,这不适用于连续页面,因为找不到“GetNextPartition()”函数。我试过最后一行:
tracks = tracks.collection.GetNextPartition()
...但没有成功。
也许我把版本搞混了?但我在从这里下载版本后尝试使用 Python 3.4 运行它:https://github.com/soundcloud/soundcloud-python
非常感谢任何帮助!
【问题讨论】:
标签: python pagination soundcloud