Jump to content

It's a Python code question for the workflow

Recommended Posts

I'd like to know how to modify the code in order to place the currently entered search word at the bottom of the autocomplete list.

Thank you in advance! 🙏





import sys
from workflow import web, Workflow

def get_dictionary_data(word):
    url = 'https://ac-dict.naver.com/koko/ac'
    params = dict(frm='stdkrdic', oe='utf8', m=0, r=1, st=111, r_lt=111, q=word)
    r = web.get(url, params)
    return r.json()

def main(wf):
    import cgi;
    args = wf.args[0]
    wf.add_item(title = 'Search Naver Krdic for \'%s\'' % args,
    def wrapper():
        return get_dictionary_data(args)
    res_json = wf.cached_data("kr_%s" % args, wrapper, max_age=600)
    for items in res_json['items']:
        for ltxt in items:
            if len(ltxt) > 0:
                txt = ltxt[0][0]
                wf.add_item(title = u"%s" % txt ,
                            subtitle = 'Search Naver Krdic for \'%s\'' % txt,
if __name__ == '__main__':
    wf = Workflow()


Edited by greedist
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...