I am trying to return email addresses from a website using mechanize. I am very easily able to determine whether or not the "@" symbol is found on the page by using the code below.
However, I would like to return the characters surrounding the @ symbol to determine whether or not it might be an email address. Anyone know how I might be able to return the surrounding characters once the @ is found?
I know mechanize can return links, but the email address might not be a link. Thanks!
require 'mechanize'
mechanize = Mechanize.new { |agent|
agent.open_timeout = 4
agent.read_timeout = 4
agent.max_history = 0
agent.follow_meta_refresh = true
agent.keep_alive = false
}
website = ARGV[0]
keyword = "@"
page = mechanize.get(website)
if page.body.include?(keyword)
puts "found \"#{keyword}\" on #{website}"
else
puts "not found"
end