Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

An AppleScript to look up phone numbers in Google Internet
Well just bought Google Hacks and couldn't resist. Had to try at least one! Here's an AppleScript to look up phone numbers using Google:
tell application "Finder"
  try
    display dialog "enter full first name lowercase" default answer ¬
      "joe" buttons {"OK"} default button 1
    set first_name to text returned of the result
    display dialog "enter last name lower case" default answer ¬
      "blow" buttons {"OK"} default button 1
    set last_name to text returned of the result
    set full_name to first_name & " " & last_name
    -- The next three lines should be entereed as ONE LINE:
    display dialog ¬
      "Enter city in lower case, leave blank if you don't know it."
      default answer "my city" buttons {"OK"} default button 1
    set my_city to text returned of the result
    display dialog "Enter state as two letter abbreviation" default answer ¬
      "ca" buttons {"OK"} default button 1
    set my_state to text returned of the result
    tell application "Safari"
    -- The next two lines should be entereed as ONE LINE:
      open location "http://www.google.com/search?q=rphonebook:" & 
        first_name & " " & last_name & " " & my_city & " " & my_state
    end tell
  end try
end tell
Be careful of line wraps on the display dialog lines and the open location line at the end. Be sure to copy and paste into Script Editor and make them all one line. Save this AppleScript as a compiled script and put it in your scripts folder. From there, you can access it using Script menu in the menubar.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[7,877 views]  

An AppleScript to look up phone numbers in Google | 7 comments | Create New Account
Click here to return to the 'An AppleScript to look up phone numbers in Google' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to look up phone numbers in Google
Authored by: zeb on May 28, '03 01:56:24PM

Seems like a neat hint, but I couldn't get it to work... It would prompt me for all the info, but wouldn't do anything with Safari... hmmmm



[ Reply to This | # ]
A quicker method that does not rely on Safari
Authored by: Nafai on May 28, '03 02:11:05PM
Since I abhor Safari, but love this tip, at first I just changed the tell app portion to "Mozilla", but realized that I was doing too much work: If you are using Mozilla or a counterpart, simply make a new bookmark, and put this in the url:
http://www.google.com/search?q=rphonebook:%s
Then make the keyword whatever you want, I chose the letter "p". Now in your address bar, all you have to do is type:

p [first name] [last name] [city] [state]

and hit return. A lot faster and simpler for me than an Applescript method, and definitely preferable in my mind to using Safari. I honestly feel stupid because I didn't even know that Google HAD a phone book search until reading this, and always used the incredibly slow and tedious 411.com.

[ Reply to This | # ]
An AppleScript to look up phone numbers in Google
Authored by: robJ on May 28, '03 02:31:45PM
Handy, and scary! I'm glad that I'm not in the phone book since it takes only seconds to find a map! I'll bet the chat room child molesters love this Google feature since all they have to do is get the victim to reveal their phone number. :-(

Here's a more user-friendly version of the script that allows one to cancel execution in all dialogs. The Finder has been taken out of the script because it isn't needed, and Safari will be brought to the front to display the result.

set fma to (path to frontmost application as string)
try
	tell application fma to set first_name to text returned of ¬
		(display dialog "enter full first name lowercase" default answer "joe")
	
	tell application fma to set last_name to text returned of ¬
		(display dialog "enter last name lower case" default answer "blow")
	
	tell application fma to set my_city to text returned of ¬
		(display dialog "Enter city in lower case, leave blank" & ¬
			" if you don't know it." default answer "my city")
	
	tell application fma to set my_state to text returned of ¬
		(display dialog "Enter state as two letter abbreviation" default answer "ca")
	
	tell application "Safari"
		activate
		open location "http://www.google.com/search?q=rphonebook:" & first_name & ¬
			" " & last_name & " " & my_city & " " & my_state
	end tell
end try


[ Reply to This | # ]
further (minor) simplifications
Authored by: cclauset on May 28, '03 11:52:10PM

Google doesn't require the search string to be all lower case as suggested by the script. Also, strip out the placeholders in the default answers (i.e., joe blow my city ca) as they are unnecessary.



[ Reply to This | # ]
An AppleScript to look up phone numbers in Google
Authored by: dica on Jun 01, '03 02:25:16PM
This simplifies considerably the AppleScript and placed in the scriptmenu will work always. (will open the user selected browser)
try
   display dialog " Please enter first name, last name, city and state abbreviattion with a space between them " default answer ¬
    " " buttons {" OK ", " Cancel "} default button 1 giving up after 30
   set full_name to text returned of the result
   open location " http://www.google.com/search?q=rphonebook: " & full_name
end try


[ Reply to This | # ]
No AppleScript needed
Authored by: Krioni on May 28, '03 05:13:44PM
I love AppleScript (indeed - I write a lot of it for work and fun), but it isn't really needed for this. If you want to get the results in a browser anyway, why not just bookmark this: (Try it!)

javascript:promptMsg='Enter the first name, last name, city, state abr (as much as you know):';actionURL='http://www.google.com/search?q=rphonebook:';q=prompt(promptMsg,'');window.open(actionURL+escape(q))

It pops up a single dialog in Safari, you enter what you know, and get a new window with the results. I've got a Search category in my bookmark bar with this and many other 'bookmarklets'. There are a lot more of those in the BBS archives here.

[ Reply to This | # ]

An AppleScript to look up phone numbers in Google
Authored by: tomem on May 29, '03 10:34:58AM

That javascript just points up the fact that you can type that stuff into a Google search (or the Safari equivalent) and phone listings will come up first. Programming may become a lost art if this keeps up!

---
TomEM
Crofton, MD



[ Reply to This | # ]