I am new to this, so sorry if I am a little short here.
How do I convert this to Alfred and return the data to alfred, and can open the URL via alfred ?
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import json
import urllib2
if len(sys.argv) < 2:
print ("Please add a search query")
sys.exit(1)
search = str(sys.argv[1])
req = urllib2.Request("http://example.com/?query="+search, None, {'user-agent':'json/'})
opener = urllib2.build_opener()
f = opener.open(req)
d = f.read()
u = json.loads(d)
if 'entries' in u.keys():
for info in u['entries']:
country = info['country']
zip = info['zip']
state = info['state']
name = info['name']
adress = info['adress']
url = 'http://example.com/s...kup/p?zip=' zip
print name.encode('utf-8')+" -", adresse.encode('utf-8'), zip, state.encode('utf-8')