Trouble with encoding special characters for search


#1

I am having a lot of trouble with encoding character ‘/’ in order to use it in streaming twitter api with twython.

I have tried doing this in a couple of ways. First:

‘EUR/USD’.replace(’/’,’%2F’)

but the search is not returning anything.

I also tried:

urllib.quote(‘EUR/USD’, ‘’)

and while the output with print is the same (EUR%2FUSD) the search is still not returning any results.

Finally I tried double encoding:

urllib.quote(urllib.quote(‘EUR/USD’, ‘’),’’)

where I get EUR%252FUSD but still no results.

Furthermore, search does work properly on EURUSD, but only when it is preceded by the symbol $ in the tweet itself. In case the dollar sign is missing search also won’t detect the tweet.

Anyone has an idea of what might be going on here?


#2

It’s difficult to tell from your post whether you’re using the Streaming API’s track feature or you are using the Search API. Can you clarify?

Both APIs normalize some punctuation and other characters, but each does so a little differently. It might not be possible to search for the exact term you’re trying to match.


#3

Yeah, sorry about that, I am using Streaming API’s track feature.


#4

%2F does work, like this…

https://stream.twitter.com/1.1/statuses/filter.json?track=usd%2Fcad

Could the issue lie in twython?