Created
April 26, 2013 20:00
-
-
Save manvscode/5470059 to your computer and use it in GitHub Desktop.
Scrap emails in Ruby.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!ruby | |
require 'net/http' | |
require 'uri' | |
def scrapEmails( urlString ) | |
url = URI.parse( urlString ) | |
req = Net::HTTP::Get.new(url.path) | |
res = Net::HTTP.start(url.host, url.port) { |http| http.request(req) } | |
emails = res.body.scan( /[A-Za-z0-9]+[@ | (at) | (AT) ][A-Za-z0-9]+\.[A-Za-z]+/i ) | |
return emails | |
end | |
email_addresses = scrapEmails( ARGV[ 0 ] ) | |
email_addresses.length.times { |i| puts (i + 1).to_s + " " + email_addresses[ i ] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment