Sha256: 4391c8c1225015981d1f0141cae3b844fe5deb3532551ca9214a2cce262d539a

Contents?: true

Size: 737 Bytes

Versions: 13

Compression:

Stored size: 737 Bytes

Contents

# frozen_string_literal: true

require "urlscan"

module Miteru
  class Feeds
    class UrlScan < Feed
      attr_reader :size

      def initialize(size = 100)
        @size = size
        raise ArgumentError, "size must be less than 10,000" if size > 10_000
      end

      def api
        @api ||= ::UrlScan::API.new
      end

      def urls
        urls_from_community_feed
      rescue ::UrlScan::ResponseError => e
        puts "Failed to load urlscan.io feed (#{e})"
        []
      end

      private

      def urls_from_community_feed
        res = api.search("task.method:automatic", size: size)

        results = res["results"] || []
        results.map { |result| result.dig("task", "url") }
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
miteru-1.1.0 lib/miteru/feeds/urlscan.rb
miteru-1.0.2 lib/miteru/feeds/urlscan.rb
miteru-1.0.1 lib/miteru/feeds/urlscan.rb
miteru-1.0.0 lib/miteru/feeds/urlscan.rb
miteru-0.14.7 lib/miteru/feeds/urlscan.rb
miteru-0.14.6 lib/miteru/feeds/urlscan.rb
miteru-0.14.5 lib/miteru/feeds/urlscan.rb
miteru-0.14.4 lib/miteru/feeds/urlscan.rb
miteru-0.14.3 lib/miteru/feeds/urlscan.rb
miteru-0.14.2 lib/miteru/feeds/urlscan.rb
miteru-0.14.1 lib/miteru/feeds/urlscan.rb
miteru-0.14.0 lib/miteru/feeds/urlscan.rb
miteru-0.13.0 lib/miteru/feeds/urlscan.rb