Add /humans.txt check

See http://humanstxt.org/
This commit is contained in:
g0tmi1k
2018-05-09 16:33:44 +01:00
parent dc48008d43
commit 6c0a21c80d
4 changed files with 157 additions and 0 deletions

View File

@@ -1,10 +1,12 @@
# encoding: UTF-8
require 'web_site/robots_txt'
require 'web_site/humans_txt'
require 'web_site/interesting_headers'
class WebSite
include WebSite::RobotsTxt
include WebSite::HumansTxt
include WebSite::InterestingHeaders
attr_reader :uri

View File

@@ -0,0 +1,39 @@
# encoding: UTF-8
class WebSite
module HumansTxt
# Checks if a humans.txt file exists
# @return [ Boolean ]
def has_humans?
Browser.get(humans_url).code == 200
end
# Gets a humans.txt URL
# @return [ String ]
def humans_url
@uri.clone.merge('humans.txt').to_s
end
# Parse humans.txt
# @return [ Array ] URLs generated from humans.txt
def parse_humans_txt
return unless has_humans?
return_object = []
response = Browser.get(humans_url.to_s)
entries = response.body.split(/\n/)
if entries
entries.flatten!
entries.uniq!
entries.each do |d|
temp = d.strip
return_object << temp.to_s
end
end
return_object
end
end
end