Sha256: e842a62e64191216fe58c49d9dd14cb760a3ed72af3746bfd12ce5b561ed0dcf
Contents?: true
Size: 901 Bytes
Versions: 4
Compression:
Stored size: 901 Bytes
Contents
# frozen_string_literal: true require "digest/md5" require "oga" module WhatWeb module Helper refine HTTP::Response do def md5sum Digest::MD5.hexdigest(body.to_s) end def text doc = Oga.parse_html(body.to_s.force_encoding('UTF-8')) path = /\A<body(?:\s|>)/i.match?(body.to_s) ? '/html/body' : '/html/body/node()' nodes = doc.xpath(path) nodes.map(&:text).join end def tag_pattern # remove stuff between script and /script # don't bother with !--, --> or noscript and /noscript inscript = false; body.to_s.scan(/<([^\s>]*)/).flatten.map do |x| x.downcase! r = nil r = x if inscript == false inscript = true if x == "script" (inscript = false; r = x) if x == "/script" r end.compact.join(",") end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
simple_whatweb-0.4.1 | lib/whatweb/helper.rb |
simple_whatweb-0.4.0 | lib/whatweb/helper.rb |
simple_whatweb-0.3.0 | lib/whatweb/helper.rb |
simple_whatweb-0.2.1 | lib/whatweb/helper.rb |