问题
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