# Download a comic strip and email to myself with Ruby?

**URL:** <https://www.ruby-forum.com/t/download-a-comic-strip-and-email-to-myself-with-ruby/168813>\
**Category:** Ruby\
**Created:** [May 26, 2009, 10:54am UTC](https://www.ruby-forum.com/t/download-a-comic-strip-and-email-to-myself-with-ruby/168813 "2009-05-26T10:54:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 26, 2009, 10:54am UTC](https://www.ruby-forum.com/t/download-a-comic-strip-and-email-to-myself-with-ruby/168813/1 "2009-05-26T10:54:22Z")

</div>

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](http://comics.com/peanuts)

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 26, 2009, 11:04am UTC](https://www.ruby-forum.com/t/download-a-comic-strip-and-email-to-myself-with-ruby/168813/2 "2009-05-26T11:04:32Z")

</div>

On Tue, May 26, 2009 at 10:54 AM, SpringFlowers AutumnMoon  
[removed\_email\_address@domain.invalid](mailto: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](http://comics.com/peanuts)

Yes

Andrew T.  
[http://ramblingsonrails.com](http://ramblingsonrails.com)

[http://MyMvelope.com](http://MyMvelope.com) - The SIMPLE way to manage your savings

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 26, 2009, 8:58pm UTC](https://www.ruby-forum.com/t/download-a-comic-strip-and-email-to-myself-with-ruby/168813/3 "2009-05-26T20:58:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 26, 2009, 8:44pm UTC](https://www.ruby-forum.com/t/download-a-comic-strip-and-email-to-myself-with-ruby/168813/4 "2009-05-26T20:44:27Z")

</div>

Andrew T. wrote:

> On Tue, May 26, 2009 at 10:54 AM, SpringFlowers AutumnMoon  
> [removed\_email\_address@domain.invalid](mailto: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](http://comics.com/peanuts)
> 
> Yes

how is it done?

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 26, 2009, 9:12pm UTC](https://www.ruby-forum.com/t/download-a-comic-strip-and-email-to-myself-with-ruby/168813/5 "2009-05-26T21:12:09Z")

</div>

On Tue, May 26, 2009 at 8:57 PM, Alex [removed\_email\_address@domain.invalid](mailto: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://ramblingsonrails.com)

[http://MyMvelope.com](http://MyMvelope.com) - The SIMPLE way to manage your savings

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 26, 2009, 9:30pm UTC](https://www.ruby-forum.com/t/download-a-comic-strip-and-email-to-myself-with-ruby/168813/6 "2009-05-26T21:30:14Z")

</div>

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](http://comics.com/peanuts)

As for downloading a file:

> **[Downloading a file](http://al2o3-cr.blogspot.com/2008/08/downloading-file.html)**
>
> Today we will download a Garfield comic strip. We will not display it, as displaying is a whole lot harder, it needs a window and so on, may...

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 26, 2009, 9:15pm UTC](https://www.ruby-forum.com/t/download-a-comic-strip-and-email-to-myself-with-ruby/168813/7 "2009-05-26T21:15:38Z")

</div>

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](http://smtp.my-isp.com) to send it? is there  
any other way?

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [May 26, 2009, 9:56pm UTC](https://www.ruby-forum.com/t/download-a-comic-strip-and-email-to-myself-with-ruby/168813/8 "2009-05-26T21:56:11Z")

</div>

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
