0

am using this part of code to get trends about Egypt `Egypt_WOE_ID = 23424802

Egypt_trends = twitter_api.trends.place(_id=Egypt_WOE_ID)

print Egypt_trends` the problem is instead of getting the actual hastags and trends i get symobls doesn't mean any thing , this is a part of the output :-

[{u'created_at': u'2017-02-20T12:41:44Z', u'trends': [{u'url': u'http://twitter.com/search?q=%23%D9%85%D8%B0%D8%A8%D8%AD%D9%87_%D8%A8%D9%88%D8%B1%D8%B3%D8%B9%D9%8A%D8%AF', u'query': u'%23%D9%85%D8%B0%D8%A8%D8%AD%D9%87_%D8%A8%D9%88%D8%B1%D8%B3%D8%B9%D9%8A%D8%AF', u'tweet_volume': None, u'name': u'#\u0645\u0630\u0628\u062d\u0647_\u0628\u0648\u0631\u0633\u0639\u064a\u062f', u'promoted_content': None}, {u'url': u'/search?q=%23JFT74', u'query': u'%23JFT74', u'tweet_volume': None, u'name': u'#JFT74', u'promoted_content': None}, {u'url': u'/search?q=%23%D8%A8%D9%84%D8%A7%D9%87%D8%A7_%D9%84%D8%AD%D9%88%D9%85_%D9%81%D8%B1%D8%A7%D8%AE_%D8%B3%D9%85%D9%83', u'query': u'%23%D8%A8%D9%84%D8%A7%D9%87%D8%A7_%D9%84%D8%AD%D9%88%D9%85_%D9%81%D8%B1%D8%A7%D8%AE_%D8%B3%D9%85%D9%83', u'tweet_volume': None, u'name': u'#\u0628\u0644\u0627\u0647\u0627_\u0644\u062d\u0648\u0645_\u0641\u0631\u0627\u062e_\u0633\u0645\u0643', u'promoted_content': None}, {u'url': u'/search?q=%23%D8%A7%D9%85_%D8%AE%D8%AF%D8%A7%D8%B4_%D8%AA%D9%85%D8%A7%D8%B1%D8%B3_%D8%A7%D9%84%D8%AC%D9%86%D8%B3', u'query': u'%23%D8%A7%D9%85_%D8%AE%D8%AF%D8%A7%D8%B4_%D8%AA%D9%85%D8%A7%D8%B1%D8%B3_%D8%A7%D9%84%D8%AC%D9%86%D8%B3', u'tweet_volume': 14030, u'name': u'#\u0627\u0645_\u062e\u062f\u0627\u0634_\u062a\u0645\u0627\u0631\u0633_\u0627\u0644\u062c\u0646\u0633', u'promoted_content': None}]

thanks in advance , and please forgive me if my English bad or any thing.i will try to add and update any thing i found or any note any one tell me about it to make the question looks better.

Nasr
  • 65
  • 1
  • 12

1 Answers1

0

Your strings containing % are url encoded. You can convert them with:

# Python 3
import urllib.parse 
s='%23%D9%85%D8%B0%D8%A8%D8%AD%D9%87_%D8%A8%D9%88%D8%B1%D8%B3%D8%B9%D9%8A%D8%AF'
urllib.parse.unquote(s)
# '#مذبحه_بورسعيد'



# Python 2
import urllib
s='%23%D9%85%D8%B0%D8%A8%D8%AD%D9%87_%D8%A8%D9%88%D8%B1%D8%B3%D8%B9%D9%8A%D8%AF'
urllib.unquote(s)
# '#مذبحه_بورسعيد'
Thierry Lathuille
  • 23,663
  • 10
  • 44
  • 50
  • man i wish i could give you the right mark , but i dont have enouph reputation , thank you very much , another question , how can i convert them all at once ? and thanks sir – Nasr Feb 20 '17 at 13:24
  • hey bro when i run it , it tell me 'ImportError: No module named parse ' am using python2 by the way – Nasr Feb 20 '17 at 13:42
  • brother every thing work fine , but add ,, print urllib.unquote(s) ,, to get real output , thank you very much , and plz if u can tell me code to make all entire code and url decoded at once ,thanks agien :))) @Thierry Lathuille – Nasr Feb 20 '17 at 15:16