Page 1 of 1

A way to search your current website with google ?

Posted: Wed Feb 03, 2010 3:55 pm
by varmemester
Is there a way to search your current website with google, through launchbar. This would be really handy indeed.

Best,
varmemester

Re: A way to search your current website with google ?

Posted: Sun Feb 21, 2010 11:46 am
by dylanpetter
I second this request, in fact, searching your current application in general would be very useful.

Re: A way to search your current website with google ?

Posted: Sat Mar 27, 2010 5:10 pm
by Cottser
If you're using Safari, here's a fun tip.

Get the Google Site Search bookmarklet from here:
http://www.imilly.com/bm.htm

Add it to your bookmark bar. If you have it in the first nine positions, you can access it via keyboard shortcut. For example, put it on the far left of your bookmark bar, then press Cmd-1 to bring it up. Very handy.

I'm not sure if other browsers offer these types of shortcuts.

Re: A way to search your current website with google ?

Posted: Sat Mar 27, 2010 10:15 pm
by ptujec
this should be close to a solution

Code: Select all

on handle_string(s)
   
   tell application "Safari"
      set theURL to URL of front document
      set theSearchQ to "http://www.google.com/search?q=site:" & theURL & " " & s
      open location theSearchQ
      activate
   end tell
   
end handle_string

Re: A way to search your current website with google ?

Posted: Tue Mar 30, 2010 1:26 pm
by norbert
ptujec, thanks for your script! It would be necessary though, to the extract the hostname from the current document's URL. Otherwise the search would be restricted to the current page instead of the entire site.

A simple approach might extract the substring between the first '//' and the following '/'.

Re: A way to search your current website with google ?

Posted: Wed Aug 07, 2013 9:46 am
by ptujec
While googling for a solution to this problem I found my own entry ;) I "researched" a bit more and here is the result:

Code: Select all

-- An AppleScript to Google search the current site in Safari - Mac OS X Hints -  http://hints.macworld.com/article.php?story=20071201151055199
-- modified for use with LaunchBar 2013-08-07 by Ptujec

on handle_string(s)
   
   -- set s to text returned of (display dialog "Enter search object" default answer "")
   tell application "Safari"
      set url_current to URL of front document
      set url_current to text ((offset of ":" in url_current) + 3) through length of url_current
      set url_current to text 1 through ((offset of "/" in url_current) - 1) of url_current
      set new_url to "http://www.google.com/search?q=site:" & url_current & " " & s
      make new document
      activate
      set URL of front document to new_url
   end tell
   
end handle_string

on run
   set s to text returned of (display dialog "Enter search object" default answer "")
   tell application "Safari"
      set url_current to URL of front document
      set url_current to text ((offset of ":" in url_current) + 3) through length of url_current
      set url_current to text 1 through ((offset of "/" in url_current) - 1) of url_current
      set new_url to "http://www.google.com/search?q=site:" & url_current & " " & s
      make new document
      activate
      set URL of front document to new_url
   end tell
   
end run

Re: A way to search your current website with google ?

Posted: Sat Jun 21, 2014 11:03 am
by DocterD
Hi,

I wrote an Action for this. It grabs the Default Browser (Safari or Chrome). Gets the Domain and sends it to Google's site search. Have fun.

https://github.com/docterd/launchbar