KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am requesting youtube search terms for use with jquery autocomplete, but am having a hard time converting the URL response into a proper format. In my (Django/Python) view I do: data2 = urllib2.urlopen('http://suggestqueries.google.com/complete/search?hl=en&ds=yt&client=youtube&hjson=t&jsonp=window.yt.www.suggest.handleResponse&q=jum&cp=3') (I hardcoded the search term = 'jump' for simplicity) If I do data2.read() I get what I believe is JSON (copy-pasting the url into a browser also returns this.) window.yt.www.suggest.handleResponse(["jum",[["jumpstyle","","0"],["jump","","1"],["jump around","","2"],["jump on it","","3"],["jumper","","4"],["jump around house of pain","","5"],["jumper third eye blind","","6"],["jumbafund","","7"],["jump then fall taylor swift","","8"],["jumpstyle music","","9"]],"","","","","",{}]) I need to return this in a format that jquery autocomplete can read. I know it will work if I can get it into a list, for example, mylist = ['jumpstyle', 'jump', 'jump around', ...] and then convert it back into json before returning it: json.dumps(mylist) (This works if I directly define mylist directly as written above.) But I cannot get from the data that is returned by the URL to either a simple list (which I then convert back into JSON) or to some form of JSON that I can return directly to be used by auto complete. I've tried, among other things, j2 = json.loads(data2) and j2 = json.loads(data2.read()) Hope someone can help!
Tags (comma-separated)
Save Edits
Cancel