Jump to content

Making json object open webpages with Python

Recommended Posts


I want to make my objects open up web pages with Python, is there any way to do this? I would have to create urls with each iteration and inserting into the object/dictionary so every game is assigned a url. The first object in the image would for example open the game's boxscore with the user's default browser.


There is no query in my script.


def get_alfred_items():
  results = []
  url = "https://www.alfredapp.com/workflows/"
  for i, j in zip(scores_list, player_leaders):
  		"title": f"{i[0]} {i[1]} - {i[2]} {i[3]} ({gametime_list[scores_list.index(i)]})", # [home] [pts] - [pts] [away]
  		"subtitle": f"{j[0]}: {j[1]}pts/{j[2]}reb/{j[3]}ast - {j[4]}: {j[5]}pts/{j[6]}reb/{j[7]}ast",
      		"url": url + i[0], # I WANT TO DO THIS
  return results

if __name__ == "__main__":
    alfred_json = json.dumps({
        "items": get_alfred_items()


Link to comment

welcome @bjornelvar!

assuming that you want to open the site upon actioning the result (ie pressing enter), you can pass the URL as an argument (basically replacing  "url" with "arg" in your script below), and then connecting the script filter to a 'Open URL' object. This should also work as Quick Look url (tapping shift or ⌘Y, to see a preview without actioning). 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...