# Get Source Code of a http://... site?

**URL:** <https://www.ruby-forum.com/t/get-source-code-of-a-http-site/165953>\
**Category:** Ruby\
**Created:** [April 20, 2009, 10:35am UTC](https://www.ruby-forum.com/t/get-source-code-of-a-http-site/165953 "2009-04-20T10:35:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 20, 2009, 10:35am UTC](https://www.ruby-forum.com/t/get-source-code-of-a-http-site/165953/1 "2009-04-20T10:35:03Z")

</div>

Hi all

I want to download the source code of a website using Ruby? How can I  
achieve this? …when searching with Google, I only get download links  
for the Ruby source etc. 😉

Thanks  
Josh

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 20, 2009, 10:43am UTC](https://www.ruby-forum.com/t/get-source-code-of-a-http-site/165953/2 "2009-04-20T10:43:44Z")

</div>

2009/4/20 Joshua M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I want to download the source code of a website using Ruby? How can I  
> achieve this? …when searching with Google, I only get download links  
> for the Ruby source etc. 😉

The source code of a web site is usually not available apart from the  
JavaScript you see in pages - for good reasons (security,  
copyright…).

Cheers

robert

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 20, 2009, 10:46am UTC](https://www.ruby-forum.com/t/get-source-code-of-a-http-site/165953/3 "2009-04-20T10:46:10Z")

</div>

Robert K. wrote:

> 2009/4/20 Joshua M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > I want to download the source code of a website using Ruby? How can I  
> > achieve this? …when searching with Google, I only get download links  
> > for the Ruby source etc. 😉
> 
> The source code of a web site is usually not available apart from the  
> JavaScript you see in pages - for good reasons (security,  
> copyright…).
> 
> Cheers
> 
> robert

Oh, I wasn’t clear enough, I just need the XHTML code, no  
behind-the-scenes Ruby or PHP or stuff. 😉

It’s because I want to use [captchator.com](http://captchator.com) and I need to check the result  
(0 or 1) using an URL like this:

[http://captchator.com/captcha/check\_answer/#{captcha\_code}/#{@comment.captcha}](http://captchator.com/captcha/check_answer/#%7Bcaptcha_code%7D/#%7B@comment.captcha%7D)

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 20, 2009, 10:50am UTC](https://www.ruby-forum.com/t/get-source-code-of-a-http-site/165953/4 "2009-04-20T10:50:11Z")

</div>

2009/4/20 Joshua M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Oh, I wasn’t clear enough, I just need the XHTML code, no  
> behind-the-scenes Ruby or PHP or stuff. 😉

There are mechanize, hpricot and a few other alternatives that can  
help you there.

Cheers

robert

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 20, 2009, 11:04am UTC](https://www.ruby-forum.com/t/get-source-code-of-a-http-site/165953/5 "2009-04-20T11:04:51Z")

</div>

Robert K. wrote:

> 2009/4/20 Joshua M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > Oh, I wasn’t clear enough, I just need the XHTML code, no  
> > behind-the-scenes Ruby or PHP or stuff. 😉
> 
> There are mechanize, hpricot and a few other alternatives that can  
> help you there.
> 
> Cheers
> 
> robert

Thanks, but that would be a big overkill I guess. I found the following  
site which explains how to do it with just a few original methods:

> **[ThemBid.com is for sale | HugeDomains](https://www.hugedomains.com/domain_profile.cfm?d=thembid.com)**
>
> Premium domains add authority to your site. Transparent pricing. 1 year WHOIS privacy included. 30-day money back guarantee.

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 21, 2009, 12:54am UTC](https://www.ruby-forum.com/t/get-source-code-of-a-http-site/165953/6 "2009-04-21T00:54:35Z")

</div>

If you just need to get it, for archive or something, and just chose  
ruby, have a look at httrack. Not ruby, just its own app, but it  
mirrors pages.

- Daniel

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 21, 2009, 1:04am UTC](https://www.ruby-forum.com/t/get-source-code-of-a-http-site/165953/7 "2009-04-21T01:04:55Z")

</div>

Daniel Huckstep wrote:

> If you just need to get it, for archive or something, and just chose  
> ruby, have a look at httrack. Not ruby, just its own app, but it  
> mirrors pages.
> 
> - Daniel

Thanks, I know httrack… had some problems with it lately, though…  
😉
