Instaloader-收到输入标签的媒体数量

发布于 2025-01-29 05:47:31 字数 797 浏览 4 评论 0 原文

我希望简单地输入一系列主题标签,并使用这些主题标签及其相关的后计数输出。

我相信我可以使用MediaCount属性: “与此标签相关的所有媒体的计数。” 如下所示:

但我可以保证如何为其编写代码。

我尝试过:

from instaloader import Hashtag

Inst = Instaloader()
h = Hashtag(Inst.InstaloaderContext,"coding")
print(h.mediacount)

这给我带来了这个错误:

Traceback (most recent call last):
  File "/xxx/Hashtag.py", line 7, in <module>
    h = Hashtag(instaloader.InstaloaderContext,"coding")
  File "/xxx/instaloader/structures.py", line 1453, in __init__
    assert "name" in node
AssertionError

I'm looking to simply input a series of hashtags and be outputted with those hashtags and their associated post count.

I believe I can use the mediacount property:
"The count of all media associated with this hashtag."
As found here: https://instaloader.github.io/module/structures.html?highlight=hashtag#instaloader.Hashtag

But am insure how to write the code for it.

I have tried:

from instaloader import Hashtag

Inst = Instaloader()
h = Hashtag(Inst.InstaloaderContext,"coding")
print(h.mediacount)

This left me with this error:

Traceback (most recent call last):
  File "/xxx/Hashtag.py", line 7, in <module>
    h = Hashtag(instaloader.InstaloaderContext,"coding")
  File "/xxx/instaloader/structures.py", line 1453, in __init__
    assert "name" in node
AssertionError

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鹤仙姿 2025-02-05 05:47:31

您正在使用哪个版本的Instaloader API?

我使用v4.9,以下代码可以对我有用

from instaloader import Hashtag
import instaloader

Inst = instaloader.Instaloader()
h = Hashtag.from_name(Inst.context,"coding")
print(h.mediacount)
output: 4855699

which version of instaloader APIs are you using?

I use v4.9 and the following codes can work for me

from instaloader import Hashtag
import instaloader

Inst = instaloader.Instaloader()
h = Hashtag.from_name(Inst.context,"coding")
print(h.mediacount)
output: 4855699
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文