carolineartz
3/12/2015 - 9:00 PM

ruby script for submitting uris to easysol.net/explorer for dmarc preparedness

ruby script for submitting uris to easysol.net/explorer for dmarc preparedness

require 'uri'
require 'open-uri'
require "net/http"
require 'csv'
require 'nokogiri'
require 'mechanize'



CSV.foreach("urls.csv") do |line|
  agent = Mechanize.new
  agent.set_proxy('10.0.1.12', '9396') #this is for logging/debugging http requests
  dmarc_explorer = 'http://www.easysol.net/resources/dmarc-explorer'
  page = agent.get(dmarc_explorer)
  script_body = page.search("script")[24] #this is the text of the script with the generated easy_control value for the current load
  easy_control = script_body.to_s.gsub(/(.+)(value=\")(.+)(">.+)/mx, "\\3") #extracted value for the easy_control
  params = {'txt_domain' => URI.parse(line[0]).host, 'easy_control' => easy_control}
  agent.post(dmarc_explorer, params)
end