Jump to content

Multiple arguments to multiple tabs in one query


Recommended Posts

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

@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 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 by Vero
Updated to give a better couple of examples :)
Link to comment

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

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

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

@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
  • 1 year later...

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
30 minutes ago, meeffe said:

 

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 by deanishe
Link to comment
  • 3 weeks later...

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
  • 4 months later...

@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

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