# How to reliable get the title of a web page?

**URL:** <https://www.ruby-forum.com/t/how-to-reliable-get-the-title-of-a-web-page/109731>\
**Category:** Rails\
**Created:** [July 18, 2007, 1:13pm UTC](https://www.ruby-forum.com/t/how-to-reliable-get-the-title-of-a-web-page/109731 "2007-07-18T13:13:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [July 18, 2007, 1:13pm UTC](https://www.ruby-forum.com/t/how-to-reliable-get-the-title-of-a-web-page/109731/1 "2007-07-18T13:13:46Z")

</div>

In one of my forms, i want the user to enter a url and then the title of  
the associated web page to be automatically filled in, by looking it up  
from the page.

Currently i’m doing that using hpricot, which can pull out the contents  
of the title tag, but it only pulls it out as text. This works most of  
the time, but a lot of the time i get “HTML HR TAG” or something  
similar.

Does anyone know how i can reliably get at the displayed title of any  
web page?
