tschloss Posted May 6, 2013 Share Posted May 6, 2013 Hi, (among other starter problems) I have the following problem: The below script runs fine in the Mac OSX terminal. But as an "run script" action (type "python") it hangs. When I delete the urlopen line the script runs to the end (but of course without a JSON result). The small workflow is here: http://d.pr/f/K3t So something seems to be wrong with the line "response = urllib2....": import urllib2 import urllib import json url='{query}' endpoint='http://api.longurl.org/v2/expand' params = {'url':url, 'title':'1','format':'json'} response = urllib2.urlopen(endpoint+'?'+ urllib.urlencode(params)) try: json_data = json.loads(response.read()) print 'URL: '+json_data[u'long-url'] #print 'Page title: '+json_data[u'title'] except: print 'Sorry - could not find the long URL' How can I debug this? How should I retrieve a JSON result from a webservice? Thanks in advance! Thomas Link to comment
tschloss Posted May 6, 2013 Author Share Posted May 6, 2013 Sorry, guys - I am not sure why, but the workfow works no. I have to find out how to catch an illegal URL - with a legal URL everythings works as expected Thanks Thomas 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