greedist Posted December 24, 2021 Share Posted December 24, 2021 (edited) 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) r.raise_for_status() return r.json() def main(wf): import cgi; args = wf.args[0] wf.add_item(title = 'Search Naver Krdic for \'%s\'' % args, autocomplete=args, arg=args, valid=True) 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, autocomplete=txt, arg=txt, valid=True); wf.send_feedback() if __name__ == '__main__': wf = Workflow() sys.exit(wf.run(main)) Edited December 24, 2021 by greedist Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now