Jump to content

Open different URLs based on query


Recommended Posts

Hi, 

 

I'd like to open different URLs based on a query. For example I have various stg environments representing different countries. I'd like to be able to type "stg us" and have it open the us-stg.com but also type "stg uk" and have it open uk-stg.com.

 

I had thought I could take the query and parse it in either php or python and have it return the value to the "Open URL" action but didn't know how to return the value to the "Open URL" action. 

 

Any advice would be appreciated. 

 

Thanks,

Chris
 

Link to comment

Hi, 

 

I'd like to open different URLs based on a query. For example I have various stg environments representing different countries. I'd like to be able to type "stg us" and have it open the us-stg.com but also type "stg uk" and have it open uk-stg.com.

 

I had thought I could take the query and parse it in either php or python and have it return the value to the "Open URL" action but didn't know how to return the value to the "Open URL" action. 

 

Any advice would be appreciated. 

 

Thanks,

Chris

 

 

It might be better to just add a few custom searches. Find them in Alfred Preferences > Features > Web Search > Search

 

For this example you would add two custom searches (each bullet represents one custom search):

  • Keyword: 'stg uk', URL: 'http://uk-stg.com' Title: 'STG (United Kingdom)'
  • Keyword: 'stg us', URL: 'http://us-stg.com' Title: 'STG (United States)'

With this approach, you could completely avoid scripting (which would involve setting up error handlers, output values, etc.) and let Alfred parse your queries for you ;). It would be faster, too

 

If you want to send text from one workflow object to another, set your script to echo the desired text. Then use '{query}' in the next item to catch that text.

 

Cheers :)

Link to comment

Thanks for the help! I didn't know about the custom searches so that's good to know. 

 

Regarding the option to send text from one workflow object to another I tried that but it didn't seem to work. I'll revisit it again to make sure I'm doing it right. In the end I googled up a bit of applescript and used that instead. No error handlers though haha. 

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...