python - Prepare a string for Google Ajax Search? -


i have strings such as

["tabula rasa", "façade", "dj tiësto"] 

i'm accessing google ajax api in python using base url:

base = 'http://ajax.googleapis.com/ajax/services/search/web'    '?v=1.0&q=%s' 

i'm having issues using these strings plain , noticed have transform characters,

eg. "tabula rasa" -->  "tabula%20rasa" 

but have huge list of these strings , not know of way can automatically prepare these string url query.

any appreciated.

what you're looking urllib.quote():

>>> urllib.quote("tabula rasa") 'tabula%20rasa' 

the non-ascii strings may need recoded encoding expected google ajax api, if don't have them in same encoding already.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -