Class: Aquatone::Collectors::Riddler
- Inherits:
-
Aquatone::Collector
- Object
- Aquatone::Collector
- Aquatone::Collectors::Riddler
- Defined in:
- lib/aquatone/collectors/riddler.rb
Constant Summary collapse
- API_BASE_URI =
"https://riddler.io"
Constants inherited from Aquatone::Collector
Aquatone::Collector::DEFAULT_PRIORITY
Instance Attribute Summary
Attributes inherited from Aquatone::Collector
Instance Method Summary collapse
Methods inherited from Aquatone::Collector
descendants, #execute!, #initialize, meta, meta=, priority, sluggified_name
Constructor Details
This class inherits a constructor from Aquatone::Collector
Instance Method Details
#run ⇒ Object
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 |
# File 'lib/aquatone/collectors/riddler.rb', line 13 def run auth_response = post_request("#{API_BASE_URI}/auth/login", { :email => get_key("riddler_username"), :password => get_key("riddler_password") }.to_json, { :headers => { "Content-Type" => "application/json" } }) if auth_response.code == 400 or auth_response.parsed_response["meta"]["code"] == 400 failure("Invalid credentials to Riddler.io") elsif auth_response.code != 200 or auth_response.parsed_response["meta"]["code"] != 200 failure("Riddler.io auth API returned unexpected response code: #{response.code}") end token = auth_response.parsed_response["response"]["user"]["authentication_token"] response = post_request("#{API_BASE_URI}/api/search", { :query => "pld:#{url_escape(domain.name)}", :output => "host", :limit => 500 }.to_json, { :headers => { "Content-Type" => "application/json", "Authentication-Token" => token } }) response.parsed_response.each do |record| add_host(record["host"]) unless record["host"].empty? end end |