Download a comic strip and email to myself with Ruby?


#1

using Ruby on my local Windows machine, can I easily write a script to
download a comic strip every day and email it to myself?

such as
http://comics.com/peanuts


#2

On Tue, May 26, 2009 at 10:54 AM, SpringFlowers AutumnMoon
removed_email_address@domain.invalid wrote:

using Ruby on my local Windows machine, can I easily write a script to
download a comic strip every day and email it to myself?

such as
http://comics.com/peanuts

Yes

Andrew T.
http://ramblingsonrails.com

http://MyMvelope.com - The SIMPLE way to manage your savings


#3

I would use Hpricot to parse the HTML and get the image, then any of the
Ruby email libraries to send it to yourself. It’s really a trivial
problem,
but if you’re having specific issues, I’m sure many of the people on
this
list would be willing to help.

Alex


#4

Andrew T. wrote:

On Tue, May 26, 2009 at 10:54 AM, SpringFlowers AutumnMoon
removed_email_address@domain.invalid wrote:

using Ruby on my local Windows machine, can I easily write a script to
download a comic strip every day and email it to myself?

such as
http://comics.com/peanuts

Yes

how is it done?


#5

On Tue, May 26, 2009 at 8:57 PM, Alex removed_email_address@domain.invalid wrote:

I would use Hpricot to parse the HTML and get the image, then any of the
Ruby email libraries to send it to yourself. It’s really a trivial problem,
but if you’re having specific issues, I’m sure many of the people on this
list would be willing to help.

Alex

Even easier, find out how the images are named because they are often
named yyyymmdd.jpg or similar and then just try and pull the image for
the day in question.
404 - no image
200 - you’ve got it

Andrew T.
http://ramblingsonrails.com

http://MyMvelope.com - The SIMPLE way to manage your savings


#6

Jian L. wrote:

using Ruby on my local Windows machine, can I easily write a script to
download a comic strip every day and email it to myself?

such as
http://comics.com/peanuts

As for downloading a file:
http://al2o3-cr.blogspot.com/2008/08/downloading-file.html


#7

Alex wrote:

I would use Hpricot to parse the HTML and get the image, then any of the
Ruby email libraries to send it to yourself. It’s really a trivial
problem,
but if you’re having specific issues, I’m sure many of the people on
this
list would be willing to help.

is it true that we just use the smtp.my-isp.com to send it? is there
any other way?


#8

You can use any SMTP server to email the images. I would just use
Net::SMTP
with whatever SMTP server you happen to be using. It’s true that some
ISPs
offer SMTP servers, but smtp.<your_isp>.com may not be the naming
convention
that your ISP uses.

Remember, you’re going to need to attach the image to the email as well,
so
you’ll need to create a multipart message, with the image data encoded
in
base64. I’m sure there’s a library that can handle that for you,
although
I’m not very familiar with using ruby to manipulate email messages.

Alex