gpt4 book ai didi

node.js - 使用流 API 跟踪推特主题标签(关键字)

转载 作者:搜寻专家 更新时间:2023-11-01 00:02:31 27 4
gpt4 key购买 nike

我正在尝试通过给定的主题标签或关键字来跟踪所有推文。问题是,当我使用像“动物”这样的简单关键字时,我可以流式传输推文,但当我将其更改为“animal4666”时,它就不起作用了。没有收到回复。我正在使用下面的代码。

    twit.stream('statuses/filter', { track: 'animal4666' }, function(stream) {
stream.on('data', function(data) {
console.log(util.inspect(data));
});
});

我从不同的帐户发了两条推文,如下所示:

'#animal4666a'

“#animal4666 试图找出发生了什么?”

以上推文已使用搜索 API 成功检索,但由于搜索 API 的速率限制,我需要使用流 API,以便我可以使用 node.js 每两秒检查一次新推文

我正在使用的 node.js 插件:https://github.com/jdub/node-twitter

有人可以帮忙吗?

最佳答案

如果您查看 code你正在使用的库,似乎没有什么潜在的错误
当您在跟踪参数中传递数组时,它只有一个解决方法,但事实并非如此

// Workaround for node-oauth vs. twitter commas-in-params bug
if ( params && params.track && Array.isArray(params.track) ) {
params.track = params.track.join(',')
}

因此查看 official api docs对于跟踪方法,我看到两个可能相关的注意事项。

Each phrase must be between 1 and 60 bytes, inclusive.

我认为你的更短,但要记住这一点

我认为你真正的问题是:

Exact matching of phrases (equivalent to quoted phrases in most searchengines) is not supported.

Punctuation and special characters will be considered part of the termthey are adjacent to. In this sense, "hello." is a different trackterm than "hello". However, matches will ignore punctuation present inthe Tweet. So "hello" will match both "hello world" and "my brothersays hello." Note that punctuation is not considered to be part of a#hashtag or @mention, so a track term containing punctuation will not match either #hashtags or @mentions.

您可以在线检查您的推文文本,看它是否匹配 here

关于node.js - 使用流 API 跟踪推特主题标签(关键字),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19594265/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com