繁体   English   中英

使用Python的Instagram API标记

[英]Instagram API tagging using Python

我正在尝试打印出所有带有“ Starhub”的标题文本。 它可以工作,但我只能打印总共19个文本。

发现这个功能:api.tag_recent_media(计数,max_tag_id,TAG_NAME) - https://github.com/Instagram/python-instagram

因此,我使用了该功能,但失败了。 我输入50个计数,表示希望能输出50个文本,但只能打印19个文本。

我的代码:

from instagram.client import InstagramAPI
from instagram.bind import InstagramAPIError

access_token = "289615375.008d237.5f2085b9c5c6400bab78709cee949914"
client_secret = "7f79614f8fe04a569c56f8672239cb8d"

api = InstagramAPI(access_token=access_token, client_secret=client_secret)
recent_media, next_ = api.tag_recent_media(count=50, tag_name="Starhub")

count = 0

for media in recent_media:
  try:
      print media.caption.text, "--->", media.user.username
      print ""
       count += 1

  except UnicodeEncodeError:
      pass

print count

此代码仅打印出19。因此,我尝试执行的操作是此代码。

我将其添加到我的代码中:

while next_:
 more_media, next_ = api.tag_recent_media(with_next_url=next_)
 recent_media.extend(more_media)

有错误:找不到路径变量的参数值; 标签名称。

知道如何打印带有“ Starhub”标签的所有文本吗?

我也无法使用with_next_url来工作。 我最终将'next_'变量中的max_tag_id放回tag_recent_media的'max_tag_id'参数中,这似乎可行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM