# WEIRD: hpricot causes Error 500

**URL:** <https://www.ruby-forum.com/t/weird-hpricot-causes-error-500/175406>\
**Category:** Rails\
**Created:** [September 13, 2009, 1:10am UTC](https://www.ruby-forum.com/t/weird-hpricot-causes-error-500/175406 "2009-09-13T01:10:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@jason](https://www.ruby-forum.com/u/jason)\
**Post date:** [September 13, 2009, 1:10am UTC](https://www.ruby-forum.com/t/weird-hpricot-causes-error-500/175406/1 "2009-09-13T01:10:22Z")

</div>

So this is weird. I have this in one of my controllers:

```
f = open("http://www.google.com")

```

@s = f.read

And that’s fine. I can echo @s back out in the view, and it works like  
a charm. But the second I do this (in the controller):

```
doc = Hpricot(@s)

```

I get an error 500 (internal server error). I have rubygems, open-uri,  
and hpricot all included. Any ideas what’s going on? I’m under a  
pressing deadline and this one’s really got me stumped.

Thanks in advance!!!

---

<div class="post-metadata">

**Author:** ![jason](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@jason](https://www.ruby-forum.com/u/jason)\
**Post date:** [September 13, 2009, 1:31am UTC](https://www.ruby-forum.com/t/weird-hpricot-causes-error-500/175406/2 "2009-09-13T01:31:29Z")

</div>

Quoting jason [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I get an error 500 (internal server error). I have rubygems, open-uri,  
> and hpricot all included. Any ideas what’s going on? I’m under a  
> pressing deadline and this one’s really got me stumped.

Look in the log, there is usually a stack dump. Are you sure that the  
entire  
datastructure is in @s? I.e., that the end of the HTML/XML is in the  
string.  
Also there can be parsing errors, encoding errors, etc. So find the  
error  
message/exception type in logs, or catch (rescue) it in your own code.

Jeffrey
