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

Use an AppleScript to open multiple websites at once System
As a journalist, I have a fair list of pages I visit daily - usually the first thing in the morning, and then several times in the day. Unfortunately, that also means clicking my way through a million bookmarks. Until I got sick of it, and wrote an Applescript to do it for me:
  open location "http://news.bbc.co.uk"
open location "http://www.cnn.com/"
Add as many sites in the AppleScript source as you like, and save it. Then, when you run the script, the browser you define as your default browser will open all the links above in new windows.

Depending on your bandwidth and amount of RAM, you might want to limit the number of sites. On a 640 MB 700Mhz iBook, I have 16 windows opening at the same time, but YMMV.

[Editor's note: You could also use a cron scheduler to run this script at a certain time each day, and I'm sure numerous other enhancements are possible...]
    •    
  • Currently 4.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[11,545 views]  

Use an AppleScript to open multiple websites at once | 13 comments | Create New Account
Click here to return to the 'Use an AppleScript to open multiple websites at once' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Tabbed browsers?
Authored by: Titanium Man on Jan 24, '03 10:33:52AM

Browsers like Chimera and (I think) Mozilla allow one to bookmark all open tabs. ie, open 20 pages (all in one window thanks to tabbed browsing), then select Bookmarks->Add Page to Bookmarks, and put a check in the box that says Bookmark All Tabs. Just my 2 cents.



[ Reply to This | # ]
Tabbed browsers?
Authored by: jon_ault on Jan 25, '03 07:15:11PM

You can also turn any folder of bookmarks into a tabbed bookmark (in Chimera, don't know about Mozilla).

Just Get Info on the folder & check the Tab Group option.



[ Reply to This | # ]
Scripts from Safari bookmarks bar
Authored by: sfodden on Jan 24, '03 10:37:04AM

Does anyone know a way to run scripts from the Safari bookmarks bar? I've got one that saves the URL as a link document, but the best I've been able to do is put a link to the folder and file on the bar.



[ Reply to This | # ]
Alternatively...
Authored by: gidds on Jan 24, '03 10:46:00AM
An app like MacReporter checks sites for new headlines automatically. Instead of having to look for news yourself, it's brought to you!

[ Reply to This | # ]
Enhancements
Authored by: MtnBiker on Jan 24, '03 11:38:02AM

i've been doing this for years and have evolved for Explorer, Safari, and Netscape. Started this when Frontier showed me how to do this.

Enhancement: Different sites for different days. I have sites that I check every second, third, or fifth day. I also check some sites on the 1st and 15th. If I don't check on those days, i just miss them, but these are low activity sites I want to look at periodically..

Once you figure out the date thing this is all fairly easy. I have the script in my menu script window and manually activate it.

I've edited my script to show how I do it. I hope I haven't taken out any critical parts:

set theDate to current date
weekday of theDate --result: Saturday eg
set dayMonth to day of theDate

-- twice a month
if dayMonth = 11 or dayMonth = 23 then
open location
open location
end if

if (dayMonth mod 3) = 0 then --- sites checked every day divisible by 3
open location
end if

if (dayMonth mod 5) = 0 then --- sites checked every day divisible by 5
open location
open location
end if

if (dayMonth mod 2) = 1 then -- odd days

open location
open location
else -- even days
open location
open location
end if

-- every day
open location "http://www.macosxhints.com"
open location "http://www.latimes.com/"
open location "http://www.versiontracker.com/"

if weekday of theDate is not Sunday then -- don't open these sites on Sunday.
open location "http://deal-mac.com/"
end if



[ Reply to This | # ]
Enhancements
Authored by: xyz3 on Jan 24, '03 02:44:07PM

Here is my version (Note the ignoring application responses) :

property kAllURL : {"http://www.versiontracker.com/macosx/", "www.macosxhints.com/"} --add more as needed - or read from a text file if you are so inclined

on run
repeat with kURL in kAllURL
ignoring application responses
open location (kURL as string)
end ignoring
end repeat
end run



[ Reply to This | # ]
Enhancements
Authored by: palnudb on Jan 24, '03 03:13:33PM

I have added my locations, but the script opens them one after another in the same window in IE 5 on my OS9 box. how can I fix this?



[ Reply to This | # ]
Enhancements
Authored by: palnudb on Jan 24, '03 06:17:48PM

I reworked for just IE in OS9 and used openURL and toWindow commands fixed it right up.
8)



[ Reply to This | # ]
Doesn't have to be AppleScript
Authored by: readparse on Jan 24, '03 02:57:43PM
the "open" command from the terminal also opens URLs:
open "http://www.macosxhints.com/"
You can do the same thing in a shell script:
#!/bin/sh
open "http://www.macosxhints.com/"


[ Reply to This | # ]
Doesn't have to be AppleScript
Authored by: bluehz on Jan 25, '03 10:30:18AM

This is the method I create a simple shell script (as above) and then a cronjob to run it every day/night, whatever you want...



[ Reply to This | # ]
Easier way
Authored by: Krioni on Jan 24, '03 04:56:44PM

Here's some code you can save as a Stay-Open applet. It lets you load a return-delimited list of URLs from the clipboard, or from a text file, and opens them in your default browser. It's up to the browser settings to open in new windows. That is Safari's default behavior.

on run
-- version 1.1, Daniel A. Shockley (http://www.danshockley.com)
set loadChoice to button returned of (display dialog "Load from File, Clipboard, or Quit" buttons {"Quit", "Clipboard", "File"} default button "File")
if loadChoice is "Quit" then
tell me to quit

else if loadChoice is "Clipboard" then
--load from clipboard instead of file
my loadURLs({sourceType:"clipboard"})
continue activate
else -- "File"
my loadURLs({sourceType:"file"})
continue activate
end if
end run

on reopen
set loadChoice to button returned of (display dialog "Load from File, Clipboard, or Quit" buttons {"Quit", "Clipboard", "File"} default button "File")
if loadChoice is "Quit" then
tell me to quit

else if loadChoice is "Clipboard" then
--load from clipboard instead of file
my loadURLs({sourceType:"clipboard"})
continue activate
else -- "File"
my loadURLs({sourceType:"file"})
continue activate
end if
end reopen



on loadURLs(prefs)
-- version 1.1
try
set defaultPrefs to {sourceType:"file"}
set prefs to prefs & defaultPrefs

if sourceType of prefs is "file" then
set listOfURLs to getListofURLsFromFile()
else if sourceType of prefs is "clipboard" then
set listOfURLs to getListofURLsFromClipboard()
else -- unknown sourceType
error "Unknown sourceType for getting URL list."
end if
return sendURLs(listOfURLs)
on error errMsg number errNum
error errMsg number errNum
end try
end loadURLs


on getListofURLsFromClipboard()
try
set blockOfURLs to (get the clipboard)
try
set blockOfURLs to blockOfURLs as string
on error
set blockOfURLs to ""
end try

if blockOfURLs is "" then
tell me to activate
display dialog "The clipboard could not be converted into text. Please copy your list of URLs and try again."
return false
end if
-- just in case file or clipboard is using UNIX-style line endings
set blockOfURLs to simplereplace(blockOfURLs, ASCII character 10, return)

set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
set listOfURLs to text items of blockOfURLs
set AppleScript's text item delimiters to od
return listOfURLs
on error errMsg number errNum
error errMsg number errNum
end try

end getListofURLsFromClipboard

on getListofURLsFromFile()
try
set prefFilePath to (choose file with prompt "Choose a file of return-delimited URLs") as string
set blockOfURLs to readFileByPath(prefFilePath)
if blockOfURLs is "" or testPathExists(prefFilePath) is false then
tell me to activate
display dialog "There are no saved URLs to open. The preference file is at " & prefFilePath
return false
end if
set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
set listOfURLs to text items of blockOfURLs
set AppleScript's text item delimiters to od
return listOfURLs
on error errMsg number errNum
error errMsg number errNum
end try
end getListofURLsFromFile


on sendURLs(listOfURLs)
try
repeat with oneURL in listOfURLs
open location oneURL
delay 1
end repeat
return true
on error errMsg number errNum
error errMsg number errNum
end try
end sendURLs

on readFileByPath(someFilePath)
-- version 1.0
try
set fileHandle to open for access file someFilePath

set fileContents to read fileHandle
close access fileHandle
on error errMsg number errNum
try
close access fileHandle
end try
if errNum is -39 then
set fileContents to ""
else
error errMsg number errNum
end if
end try
return fileContents
end readFileByPath

on testPathExists(inputPath)
-- version 1.4
-- from Richard Morton, on applescript-users@lists.apple.com
-- public domain, of course. :-)
-- gets somewhat slower as nested-depth level goes over 10 nested folders
if inputPath is not equal to "" then try
get alias inputPath as string
return true
end try
return false
end testPathExists

on simplereplace(thisText, oldChars, newChars)
-- version 1.1, Daniel A. Shockley http://www.danshockley.com

-- 1.1 coerces the newChars to a STRING, since other data types do not always coerce
-- (example, replacing "nine" with 9 as number replaces with "")
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to the oldChars
set the parsedList to every text item of thisText
set AppleScript's text item delimiters to the {(newChars as string)}
set the newText to the parsedList as string
set AppleScript's text item delimiters to oldDelims
return newText
end simplereplace



[ Reply to This | # ]
Easier way
Authored by: tngland on Jan 26, '03 08:22:34PM

My approach had alway been to create Applescripts, although I found each browser expected slight variations within the scripts.
Since Chimera/Navigator, though I find it much simple to create a window with the sites I want to grouped all tabbed. Then I use the "Bookmarks All Tabs" to create a single bookmark (which I can name) for all those sites. These are much easier to create, alter & access.

One of my favorites I only use on Sunday mornings. It's a grouping of the Travel, Arts & magazines sections of a number of newspapers.



[ Reply to This | # ]
Easier way
Authored by: luhmann on Apr 17, '03 09:48:14PM

Anyone figure out a "bookmark all tabs" applescript for Safari?

This site has a lot of nice safari scripts, but not that one:

http://www.apple.com/applescript/safari/



[ Reply to This | # ]