Tracking multiple hashtags using twitter stream API

三世轮回 提交于 2020-01-12 19:01:30

问题


When I access (w/ proper credentials):

https://stream.twitter.com/1/statuses/filter.json?lang=en&track=#help'

I get what I want: an unending stream of tweets with the #help hashtag.

However,

https://stream.twitter.com/1/statuses/filter.json?lang=en&track=#help,#perl

yields the error

Illegal character in fragment at index 70: https://stream.twitter.com/1/statuses/filter.json?lang=en&track=#help,#perl

which appears to be the '#' in '#perl'. How to fix?

For reference, this works fine:

https://stream.twitter.com/1/statuses/filter.json?lang=en&track=perl,#help

while this does not:

https://stream.twitter.com/1/statuses/filter.json?lang=en&track=perl,#help,#ruby

Is there a rule re not tracking more than one hashtag, or am I doing something more fundamentally wrong? Should I track '#hashtag' by just tracking 'hashtag'?


回答1:


['term1,term2']

But what about the hashtags? This link says not to use them: https://dev.twitter.com/streaming/overview/request-parameters#track

We can remove the apostrophes and spaces (in python) with

upgrades_str = re.sub('[\' \[\]]', '', upgrades_str)
upgrades_str = '[\''+format(upgrades_str)+'\']'


来源:https://stackoverflow.com/questions/12039481/tracking-multiple-hashtags-using-twitter-stream-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!