이것은 Nokogiri를 사용하는 OWA 검색 스크립트이며, SSL owa 교환 웹 사이트에 기계화합니다.
rubygems, mechanize (+ deps) 및 하이 라인이 설치되어 있어야합니다.
require 'rubygems'
require 'mechanize'
require 'logger'
require 'highline/import'
@url = 'https://email.***.***/Exchange'
@mechanize = Mechanize.new { |a| a.log = Logger.new('./log1.log') }
#In case you dont have trusted certs
@mechanize.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@mechanize.user_agent_alias = 'Windows Mozilla'
@mechanize.keep_alive = 'enable'
username = ask("Enter your username: ")
domain = ask("Enter your domain: ")
password = ask("Enter your password: ") {|q| q.echo = "*" }
@mechanize.get(@url) do |page|
form = page.forms[0]
form["username"] = domain + '\\' + username
form["password"] = password
page = form.submit
end
## Common Mailbox Schemes
@mailbox = "#{username}"
# @mailbox = "#{username}@#{domain}.#{tld}"
# @mailbox = "#{username}@#{domain}"
@inbox = @url + "/#{@mailbox}/Inbox/?Cmd=contents&Page=1&View=Unread%20Messages"
inboxlisting = @mechanize.get(@inbox) do |page|
fragment = Nokogiri::HTML(page.body)
["//img[@src='/exchweb/img/icon-msg-unread.gif']"].each do |xpathq|
puts "Found #{fragment.xpath(xpathq).count} new emails."
end
["//img[@src='/exchweb/img/icon-mtgreq.gif']"].each do |xpathq|
puts "Found #{fragment.xpath(xpathq).count} new meeting requests."
end
end
예 스크립트 출력 :
$ ruby ./owa.rb
Enter your username: john.doe
Enter your domain: mywork
Enter your password: ************
Found 31 new emails.
Found 3 new meeting requests.
질문은 어디 있나요? –