Jump to content

How to Perform a Google Search of a Website I'm Browsing - Universal Actions?


Recommended Posts

Hi all,

 

I'm new (8 days in) to Alfred and have been checking out the new Universal Actions feature which has gone live in v.4.5 today.

 

I would like to be able to perform a Google search of the content of a particular website and wondered if it's possible using Alfred...and if so, how?

 

Whilst browing a website I'd like to be able to:

 

1) Highlight the URL in the address bar of my browser,

2) Use Alfred to extract & store the 'main' URL of the website (ie - nothing after the first slash following the domain name) - call this VARIABLEA,

3) Type the thing that I want Google to search for on the site in question - call this VARIABLEB,

4) Have Alfred formulate a search along the lines of "site:VARIABLEA VARIABLEB",

5) Have Alfred pass that to Google to do the search (presumably in a new browser tab).

 

I know this is possible through Google (when not using Alfred) by typing "site:abc123.com searchquery" in the search box of a browser.

 

I don't know how to start putting this together in Alfred. I imagine it's fairly simple in the grand scheme of things but would very much appreciate some help / guidance to get me started.

 

Thank you!

Link to comment

Here you go: https://github.com/rknightuk/alfred-workflows/tree/main/workflows/search-this-site

 

Does exactly what you want (I think):

 

1. Select the URL

2. Choose "Search This Site"

3. Type your query and enter

4. Opens in default browser

 

If you open up the workflow in Alfred you'll see, as you said, that there's actually not a lot to it. I used a bash script I grabbed from elsewhere to extract the domain, then a keyword step to get input, then the "Default web search" step.

 

I haven't tested this much so let me know if there's any issues.

Link to comment

Thanks very much both @rknightuk and @deanishe for your help and your speedy replies!

 

@deanishe I have been trying your workflow and it works great as a Universal Action once I have selected the URL in the address bar. Just to be a pain I am a user of Firefox, and after choosing a Hotkey it seems as if the workflow is unable to get the URL of the frontmost browser tab. Is there anything I can tweak to enable this to work with Firefox, or is it a non-starter? I'm aware that Firefox lacks some public API's which means it can't do some things with Alfred that other browsers can.

 

Thanks again!

Link to comment
1 hour ago, JJJJ said:

Hi, I have your firefox workflow and would like to know those ways to make this one work with firefox.

 

First download and install the updated version of this workflow (I've added an External Trigger).

 

Then open the Firefox workflow’s script directory (ffass > Open Scripts Directory) and use Script Editor to save this AppleScript in it (call it “Search Site” or similar):

 

on run (argv)
	set _url to first item of argv
	tell application id "com.runningwithcrayons.Alfred" to run trigger "search-site" in workflow "net.deanishe.alfred.demo.universal-google" with argument _url
end run

 

Now you should have a new "Search Site" action available in the tab actions and bookmark/history search in the Firefox workflow. You can assign it a Hotkey by adding one to the workflow similar to the example ones.

Link to comment
10 hours ago, deanishe said:

 

First download and install the updated version of this workflow (I've added an External Trigger).

 

Then open the Firefox workflow’s script directory (ffass > Open Scripts Directory) and use Script Editor to save this AppleScript in it (call it “Search Site” or similar):

 

on run (argv)
	set _url to first item of argv
	tell application id "com.runningwithcrayons.Alfred" to run trigger "search-site" in workflow "net.deanishe.alfred.demo.universal-google" with argument _url
end run

 

Now you should have a new "Search Site" action available in the tab actions and bookmark/history search in the Firefox workflow. You can assign it a Hotkey by adding one to the workflow similar to the example ones.

Thanks a lot, works exactly as you described!

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