Heydomdom Posted December 11, 2017 Share Posted December 11, 2017 I can make a simple simple query to open a browser and load a page, but how can I enter multiple arguments separated by a space or a comma to open multiple tabs with those arguments? For instance I can easily make a single workflow as follows: "Stock" -> aapl -> http://www.google.com/finance?q={query} and that inserts "aapl" in the {query} area and returns the correct page. What I want to do is: "Stock" -> aapl, amzn, fb, sfix -> and that send the URL command 4 times, each with a a different query so that I have four open tabs, each showing the different stock price. Is there a simple way to do this? I can't figure out how to parse the query and had it open four tabs. Thanks. Link to comment
Vero Posted December 11, 2017 Share Posted December 11, 2017 @Heydomdom Welcome to the forum! Could you please fill in your Powerpack email address in your forum profile? This is only visible to admins (Andrew and myself) and allows us to confirm your Powerpack status first. We'll then be happy to help you out with your question. Cheers, Vero Link to comment
Heydomdom Posted December 11, 2017 Author Share Posted December 11, 2017 I've added the email.. You bring up a good point there as well. Is it possible for me to one day change my powerpack email as I'm phasing out my use of that email address with all my services? Link to comment
Vero Posted December 11, 2017 Share Posted December 11, 2017 (edited) @Heydomdom Thanks for filling in your details Pop an email to info@ for license-related questions and we'll be happy to help you out. With regards to your original question, take a look at these few examples depending on the outcome you want: If your queries are always the same (e.g. always the same four stock symbols) Connect one keyword to four "Open URL" objects, with each one pre-filled with one of the stock symbols. You can then type the keyword and press Enter, and all four pages will open. Entering multiple queries separately: Take a look at the built-in workflow in Alfred, under the + button in the bottom left > Examples > Simple To-Do List. In that workflow, I'm using two variables; The first is typed (the task I want to do) and the second is picked from a List Filter (the list to which I want to add it), each of which is saved in an Arg & Vars utility, then called later in the "Append to file" object to form the name of the list to which I want to add the task. @Andrew's going to share his own example for splitting a query into four as well, as another way to do it. If you then start creating your own workflow and need further help, add it to this thread and fellow users can help you get it completed Cheers, Vero Edited December 11, 2017 by Vero Updated to give a better couple of examples :) Link to comment
Andrew Posted December 11, 2017 Share Posted December 11, 2017 @Heydomdom I've quickly thrown together a workflow which achieves what you're asking for: https://www.dropbox.com/s/lbqsg4jhyrcw2f4/Google Stock.alfredworkflow?dl=0 You'll be able to edit the simple script to your liking Cheers, Andrew Link to comment
Heydomdom Posted December 12, 2017 Author Share Posted December 12, 2017 (edited) @Andrew @Vero Thank you guys so much. This is exactly what I wanted. You make it looks so simple but trust me, if you're not a programmer, that little bit of code could take me days to try and work out. Thanks again. Dominic Edited December 12, 2017 by Heydomdom Link to comment
runard Posted December 13, 2017 Share Posted December 13, 2017 I have a similar question. I have created an workflow that uses a "list filter" to ask me what sites I want to open. It lists 4 sites and one "all" option. The result is sent to "open URL action". Each item in the "list filter" is an url and the individual ones work. But the all part dosen't. I have just listed all the urls separated by comma in that item. Link to comment
deanishe Posted December 13, 2017 Share Posted December 13, 2017 2 hours ago, runard said: But the all part dosen't. I have just listed all the urls separated by comma in that item. It is called "Open URL", not "Open several URLs separated by commas"… As far as Alfred is concerned, whatever you pass to Open URL is a single URL and will be treated as such. Fundamentally, apart from File Actions, Alfred's workflow elements aren't designed to work with multiple inputs. If you want to open multiple URLs at once, you need to write your own script that splits your single input into its component parts, and passes each one to the open command. Link to comment
runard Posted December 13, 2017 Share Posted December 13, 2017 Thanks! Hmmm, that sounds like too much work for a newbie. Well, was worth a shot. Link to comment
deanishe Posted December 13, 2017 Share Posted December 13, 2017 If you post an actual example of your input, someone will help you. Link to comment
runard Posted December 14, 2017 Share Posted December 14, 2017 A shorter version would be: List filter: All (open all of the below) BGA (boardgamearena.com) Boit (boitajeux.com) Core (boardgamecore.com) Selected option gets sendt to "open URL". That is it. I can program all the singel sites, but the open all part is difficult. Link to comment
runard Posted December 14, 2017 Share Posted December 14, 2017 I found a less elegant solution. Have the List filter -> vars/args -> filter(if var not = all) -> Open URL ->filter(if var = all) -> branch to several Open URL commands So it works, but it is not elegant and has to be hard coded. Link to comment
Vero Posted December 14, 2017 Share Posted December 14, 2017 @runard Are you looking to type one keyword and have multiple URLs open (either static URLs or adding your search term to it)? If so, look in Alfred's built-in examples for "Should I watch this movie?" This example is set up for you to use one keyword to launch IMDB, Rotten Tomatoes and YouTube with the keyword you want to search for. Cheers, Vero Link to comment
runard Posted December 14, 2017 Share Posted December 14, 2017 (edited) I am looking for both option. In my list filter I want to list several sites that I can select and open. But I also want to have the option to go for the "all" option in the list so all the sites open. But I think I got a good enough solution. https://www.dropbox.com/s/mfmjgzqoprexooq/Online boardgames.alfredworkflow?dl=0 Edited December 14, 2017 by runard Link to comment
deanishe Posted December 14, 2017 Share Posted December 14, 2017 1 hour ago, runard said: That is it. I meant an example of the combined URL you need splitting and opening. What you need is a short script to split a single input into individual URLs. We need an example of that input to write a script to split it. Link to comment
meeffe Posted April 26, 2019 Share Posted April 26, 2019 Hello, Based on Andrew's workflow I modified it to work with Google Trends website and other services. For some reason it does not seem to work as expected with Google Trends. Could some of you elaborate on what's wrong? For now when I type Paris, Rome into the alfred search bar it should open the following tabs https://trends.google.pl/trends/explore?geo=IT&q=Paris https://trends.google.pl/trends/explore?geo=IT&q=Rome Instead I got https://trends.google.pl/trends/explore?geo=IT https://trends.google.pl/trends/explore?geo=IT Workflow - https://www.dropbox.com/s/rnh3dlfazvpl4k7/Google Stock (1).alfredworkflow?dl=0 Additionally is there any way of pasting keywords from a list format instead of comma separated? keyword1 keyword2 keyword 3 instead of keyword 1, keyword 2, keyword 3 Thanks, Michael Link to comment
deanishe Posted April 26, 2019 Share Posted April 26, 2019 (edited) 30 minutes ago, meeffe said: Workflow - https://www.dropbox.com/s/rnh3dlfazvpl4k7/Google Stock (1).alfredworkflow?dl=0 That appears to be Andrew's original workflow, not the one you've edited. You probably need to change this line: $url = 'http://www.google.com/finance?q=' . urlencode(trim($arg)); to this: $url = 'http://www.google.pl/trends/explore?geo=IT&q=' . urlencode(trim($arg)); 30 minutes ago, meeffe said: Additionally is there any way of pasting keywords from a list format instead of comma separated? Change this line: $args = explode(',', $argv[1]); to this: $args = explode("\n", $argv[1]); Edited April 26, 2019 by deanishe Link to comment
meeffe Posted April 26, 2019 Share Posted April 26, 2019 13 minutes ago, deanishe said: You probably need to change this line: $url = 'http://www.google.com/finance?q=' . urlencode(trim($arg)); to this: $url = 'http://www.google.pl/trends/explore?geo=IT&q=' . urlencode(trim($arg)); I did that without success Proper file here - https://www.dropbox.com/s/17gk6kejzepwk4e/Google Trends (IT) - multiple keywords.alfredworkflow?dl=0 Link to comment
deanishe Posted April 26, 2019 Share Posted April 26, 2019 Right. I see the problem. The URL isn't being properly escaped, so the shell is interpreting the &. Change this line: shell_exec('open ' . $url); to: shell_exec('open ' . escapeshellarg($url)); JJJJ and meeffe 1 1 Link to comment
meeffe Posted April 26, 2019 Share Posted April 26, 2019 wow thanks a ton! I bought you some beers - check paypal;) Thanks again. deanishe 1 Link to comment
deanishe Posted April 26, 2019 Share Posted April 26, 2019 Very kind of you @meeffe. Cheers 🍻! Link to comment
meeffe Posted May 16, 2019 Share Posted May 16, 2019 If any of you would be kind to help me with one small thing I tried to use this workflow with another tool called ahrefs.com and it works fine with single words but when I use 2,3 or 4 words in one query I get + in between in search field e.g. I used double decked ship and received double+decked+ship in a search field Ahrefs uses %20 as a space https://ahrefs.com/v3-keywords-explorer/google/us/overview?keyword=double%20decker%20ship So how to encode spaces as %20 in the following code? <?php $args = explode("\n", $argv[1]); // loop through args foreach ($args as $arg) { // create the url $url = 'https://ahrefs.com/v3-keywords-explorer/google/it/overview?keyword=' . urlencode(trim($arg)); // open the url in the default browser shell_exec('open ' . escapeshellarg($url)); } ?> Link to comment
meeffe Posted May 16, 2019 Share Posted May 16, 2019 (edited) OK I fixed it by myself I belive - I used rawurlencode instead of urlencode Edited October 8, 2019 by meeffe Link to comment
meeffe Posted October 8, 2019 Share Posted October 8, 2019 @deanishe or anyone else - could you help me with one more thing? Im sick of trying today Gogole trends has the ability to compare terms e.g. France and Spain https://trends.google.pl/trends/explore?geo=IT&q=France,Spain How to modify the code below so that every time I want to check "France" or "Italy" or "Kuba" (paste this argument into a window) it will be compared to Spain (in this example) https://trends.google.pl/trends/explore?geo=IT&q=France,Spain https://trends.google.pl/trends/explore?geo=IT&q=Italy,Spain https://trends.google.pl/trends/explore?geo=IT&q=Kubae,Spain code as a reference below <?php $args = explode("\n", $argv[1]); // loop through args foreach ($args as $arg) { // create the url $url = 'https://trends.google.pl/trends/explore?date=now%201-d&geo=IT&q=' . urlencode(trim($arg)); // open the url in the default browser shell_exec('open ' . escapeshellarg($url)); } ?> Thanks in advance, Michael Link to comment
deanishe Posted October 8, 2019 Share Posted October 8, 2019 1 minute ago, meeffe said: $url = 'https://trends.google.pl/trends/explore?date=now%201-d&geo=IT&q=Spain,' . urlencode(trim($arg)); meeffe 1 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