Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib.request
- import urllib
- import json
- def get_data():
- print('I can help you search for some items!')
- print('I can search for movies, TV shows, Music and much more! Please enter a Name, Title, or movie below and I can see if i can help!')
- user_search = input('Please enter here or press [ENTER] to exit: ')
- if user_search == '':
- quit()
- else:
- payload={'q':user_search}
- user_search=urllib.parse.urlencode(payload)
- api_url = "https://tastedive.com/api/similar?" + user_search +"&q="
- page=urllib.request.Request(api_url,headers={'User-Agent': 'Mozilla/5.0'})
- infile=urllib.request.urlopen(page).read()
- decoded = infile.decode('utf8')
- the_dictionary = json.loads(decoded)
- return the_dictionary
- results = get_data()
- for mydict in results.values():
- acc = 0
- for inf in mydict['Info']:
- print('Here is your results for: ')
- print(str(inf).replace('{','').replace('}',''))
- for res in mydict['Results']:
- acc += 1
- for val in res.values():
- print(acc,val)
Advertisement
Add Comment
Please, Sign In to add comment