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

Automatic placment of Salon news on desktop Internet
I'm a subscriber to the premium edition of Salon.com, and I like to skim through it every weekday morning while I'm having my breakfast. Thanks to AppleScript, cUrl, and cron, I can have it ready for me by the time the coffee's finished.

Read the rest of the article for the how-to...

My subscriber information is saved in a cookie. Although OmniWeb keeps track of it just fine, cUrl wants its cookies in the Netscape/Mozilla format. I downloaded Netscape, logged into Salon once with my subscriber info, deleted all the non-salon cookies, and copied the truncated cookies.txt file to ~/Library/Cookies/cookies.txt.

This is the code that I put into AppleScript (finding the date and time workarounds online somewhere I have forgotten -- sorry original author).
copy ((offset of (the month of (current date)) in 
"jan feb mar apr may jun jul aug sep oct nov dec ") + 3) / 4
as integer to mo
if mo < 10 then copy "0" & mo as string to mo
copy day of (current date) to da
if (day of (current date) < 10) then copy "0" & da as string to da
copy "http://www.salon.com/premium/downloads/Salon_" & (year of
(current date) as string) & mo & da & ".html" to getItHere
copy "~/Desktop/'Salon for " & da & " " & (month of (current date)
as string) & " " & (year of (current date) as string) & ".html" & "'" to putItThere
do shell script ("curl -b ~/Library/Cookies/cookies.txt -o " & putItThere & " " & getItHere)
I also pointed my crontab at this script to run every weekday morning at 0715, so that I can have my Salon with my breakfast.

This should work pretty much as is with any cookie-secured website, and cUrl has many other features for other things you may need to check frequently.
    •    
  • Currently 3.00 / 5
  You rated: 2 / 5 (3 votes cast)
 
[5,805 views]  

Automatic placment of Salon news on desktop | 5 comments | Create New Account
Click here to return to the 'Automatic placment of Salon news on desktop' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Shell Script
Authored by: THEM on Jun 18, '02 10:54:57PM

Here's a simple shell script that should accomplish the same thing. Save as a shell script and add it to cron for the same deal.

#! /bin/sh

savedate=`date +%d_%B_%Y`
getdate=`date +%Y%m%d`
curl -b ~/Library/Cookies/cookies.txt -o ~/Desktop/Salon_for_$savedate http://www.salon.com/premium/downloads/Salon_$getdate.html



[ Reply to This | # ]
Shell Script
Authored by: skyvue on Jun 19, '02 02:38:30AM

Could one of you guys spell out specifically how to do what you're recommending? I'm a longtime Mac user, but haven't been much of a nuts-and-bolts guy in the past, I'm afraid, so I'm not entirely sure, for example, how to save as a shell script or add to cron or...

Thanks in advance for spelling it out a bit.




[ Reply to This | # ]
Shell Script
Authored by: THEM on Jun 19, '02 03:30:40AM

To create a shell script create a new text document in TextEdit, it must be text or it wont work.

Copy and paste the code into the text docuemnt and save it.

Create a folder called bin in your Home. Move the shell script into there.

To add the file to your cron download the program CronniX rom this url: http://www.koch-schmidt.de/cronnix/

It's a nicely done program with clear documentation.



[ Reply to This | # ]
chmod is missing
Authored by: k2r on Jun 19, '02 10:23:55AM
Hi,

you will have to change the mode of the file to "executable", which is done best by issuing
chmod 755 filename_with_extension_if_any
at the commandline.

Otherwise the shell will not execute your script. The suggested mode means:
owner can read, write and execute, groupmembers and others can execute and read the file but not change it.

Some words for the unix-challanged :-)
A shell is the programm you can interact with when opening the terminal. It usually provides access to builtin commands and to commands that are individual programs.
A shell-script is just a plain textfile containing commands that can be executed by the shell, in fact, if you enter all the lines in the textfile by hand on the commandline the shell would execute them, too.
However, reocurring tasks should be automated by creating a script, that can be used like any other command once you have changed the file-permissions to executable.

You might wonder what the first line #!/something/somethingelse means.
It just tells which shell to use for executing the script. Since there are a lot of shells (bash/tcsh/sh) and scripting languages (PERL,Python) around you can write your script in any of them and just tell #!/where/it/is in the first line.

And cron is just a common way to execute commands at specific times. You can tell the system (specifically the cron-deamon) to execute a command every 30 minutes or every Friday at 1500. ChronniX is a convenient tool to use cron without touching the evil commandline.

I apologize for any confusion I have caused,
#!chris


[ Reply to This | # ]
Looks great, but... Not for NY Times!
Authored by: tochoa on Dec 27, '02 04:22:31PM

Hi,

I'm using Curl to do essentially what you are doing - except I'm downloading crossword puzzles, not articles. I've written a shell script that addresses the sites I like that _don't_ use cookies - but the one that does, The NY Times, is being a challenge.
I went through the curl docs and man pages and came up with the same idea you had, and reference a copy of my cookies.txt in ~/Library/Cookies. Then I used the -b option like this:

curl -b ~/Library/Cookies/cookies.txt -o $Month$curdate.puz http://query.nytimes.com/premium/xword/$Month$curdate.puz

(ignore the variables). This is not working, for some reason. I tried it using wget and got a little farther, but unfortunately wget does not handle https requests (which this link ends up at). Any suggestions? TIA!

Tony O



[ Reply to This | # ]