Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #4431

Re: Email Parsing

From Brian Candler <b.candler@pobox.com>
Newsgroups comp.lang.ruby
Subject Re: Email Parsing
Date 2011-05-12 15:39 -0500
Organization Service de news de lacave.net
Message-ID <1a310af168f7773526f3d74b3b9af98a@ruby-forum.com> (permalink)
References <fc0d26726bd7a41b4a6d7d590b6c0cb5@ruby-forum.com>

Show all headers | View raw


Robert Johns wrote in post #998352:
> How would I only pull links from the email's body

"Links" to me implies that this is an HTML email. In that case, just 
parse the body with an HTML parser (e.g. nokogiri). It can easily pull 
out all the A (anchor) tags with their href attributes.

If it's plain text, but contains URLs like http://..., then you can 
match the body against a regexp. e.g.

   p body.scan(%r{\bhttps?://\S+})

-- 
Posted via http://www.ruby-forum.com/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Email Parsing Robert Johns <piratej74@live.com> - 2011-05-12 15:28 -0500
  Re: Email Parsing Brian Candler <b.candler@pobox.com> - 2011-05-12 15:39 -0500
  Re: Email Parsing Robert Johns <piratej74@live.com> - 2011-05-12 16:24 -0500
  Re: Email Parsing Ryan Davis <ryand-ruby@zenspider.com> - 2011-05-12 18:57 -0500
    Re: Email Parsing Phillip Gawlowski <cmdjackryan@googlemail.com> - 2011-05-12 19:48 -0500

csiph-web