Search a Number of Sites With User Prompted Search Term

This will probably be simple for lots of you, but I'm stuck again!

I'm trying to do a google search of multiple sites using a user input at the beginning of the workflow.
So starting like this:
Prompt for User Input “Get search string”
I get the variable Searchterm
Then 'Search the web' action always prompts me after for a search term, though I did see another post on how to make it site specifc, but I think I need to open a window, enter a google url, then open a new tab and repeat with the new site specific search.
I tried this: https://www.google.ie/search?client=safari&rls=en&q=%Variable%Searchterm%+site:culturefox.ie&ie=UTF-8&oe=UTF-8&gws_rd=cr&dcr=0&ei=cbcUWqTJBMfNgAaS2KfYDw

I copied that from the address bar of safari, and it seems to work with one word, but not two words. And it doesn't seem ideal. Can someone suggest the correct way to search?
Many thanks.

The reason it's getting stuck on search terms with more than one word is because the search term hasn't been percent encoded for URLs. Fortunately, this is easily handled by adding a "Filter - Percent Encode for URL" action. Here's an example macro that searches both Google and DuckDuckGo in your default browser for the same term:

[Example] Search Multiple Sites with Same Search Term.kmmacros (2.6 KB)

I'm using an "Open URL" action for these rather than a "Search the Web" action so that the prompt isn't repeated. I also used the %Variable%SearchTerm% for the SearchTerm variable's default value in the prompt so that it will automatically display what you searched for last time; if you don't want it to do this, just delete SearchTerm's default value so that it's blank. As for searching multiple sites, just duplicate the "Open URL" action with the correct search query URL for every site you want to search. As always, feel free to ask if you have further questions!

2 Likes

That’s perfect. It’s late here, but I’ll get into that in the morning. Thanks a million!

1 Like

Hi @gglick,

I’m just on my way out, not much time to play around with that till later, but… I’m trying to google search specific sites, like:

%Variable%Searchterm% site:forum.keyboardmaestro.com
%Variable%Searchterm% site:bbc.co.uk

etc. Sorry if I wasn’t clear about that. I don’t think those URL’s will do that will they? Maybe this will work

https://www.google.ie/search?q=%Variable%Searchterm% site:forum.keyboardmaestro.com

but I’ll probably need to put a escape space code inbetween the end of the search term and the ‘site:’ , which I can work out. Sometimes writing about it gives you the solution doesn’t it? I’ll work on it. If I get stuck, I’ll come back. Thanks!

1 Like

Got it. It’s this!
https://www.google.ie/search?q=%Variable%Searchterm%+site%3Aforum.keyboardmaestro.com

Working 100%.

1 Like

Nice job figuring it out, @Damoeire! This topic inspired me to post a few similar macros I use that are designed to search the frontmost site rather than the same predetermined sites: Run a Site-Specific Search on Frontmost Website

Hopefully they’ll help at least a bit to demonstrate other useful ways of conducting site-specific searches :slightly_smiling_face:

1 Like

Perfect! Thank you so much for this example, @gglick!

2 Likes

Thanks @gglick! I was able to download the macro and edit the URLs for my needs.

I'd like to speed-up the process... I want to select the text and go. No typing in-between.

I use a Google Chrome extension called: Selection Search. Here.

I like it a lot, but it would be nice to select more than one website at the same time to search. Right now, gglick's script does that --- but I have to type in the text/search query.

It'd also be nice to have the search query open in background tabs (like the Chrome extension, if possible) and/or open in a set of organized news windows (ie. 3 websites: Left, Middle, and Right side of screen). I'd like to know how, if possible.