Sha256: 134dfa75188af68bcb64cc575aeeafdadb869cc7a74fe9adf66f8b7aafadad90
Contents?: true
Size: 734 Bytes
Versions: 2
Compression:
Stored size: 734 Bytes
Contents
# frozen_string_literal: true require "http" require "json" module Osakana class Urlscan BASE_URL = "https://urlscan.io/api/v1/search/" def lookup(query, size: 100) res = HTTP.get(BASE_URL, params: { q: query, size: size }) return [] unless res.code == 200 websites = [] json = JSON.parse(res.body.to_s) results = json.dig("results") || [] results.each do |item| domain = item.dig("page", "domain") ipv4 = item.dig("page", "ip") time = item.dig("task", "time") websites << Website.new(domain: domain, ipv4: ipv4, date: time) end websites end def self.lookup(query, size: 100) new.lookup(query, size: size) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
osakana-0.4.0 | lib/osakana/urlscan.rb |
osakana-0.3.0 | lib/osakana/urlscan.rb |