12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/infunnel_cli/cli/email.rb', line 12
def find( id )
email = EloquaApiService::Email.new(account: options[:account])
body = email.find(id: id)
puts body
if body.nil?
puts "\e[31m" + "#{id} not found"
return
end
puts '#' * 90
puts "\e[36m" + " Email name: #{body[:name]} (id: #{id})" + "\e[0m"
puts body[:hyperlinks].map.count
html = body[:htmlContent][:html]
puts "Rows: " + html.count("\n").to_s
n = Nokogiri::HTML.parse(html)
puts '-' * 90
n.css('a').each_with_index do |link, index|
puts "Link #{index + 1}:"
puts link[:href] =~ /\A#{URI::regexp()}\z/ ? 'Valid link' : 'invalid link'
puts link[:href]
puts link.to_s if options[:full]
puts ''
puts 'Params: '
unless link[:href] == ""
uri = URI.parse(link[:href])
params = CGI.parse(uri.query)
params.each do |param|
puts "#{param[0]}:"
puts "#{param[1].join(', ')}"
puts
end
end
puts '-' * 90
end
puts html.gsub(/<a /).count
end
|