Sha256: 8d9464b2596aafe264496fe2b5e0abd223c84151452f0e023c1a95a3528d5d87
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
# frozen_string_literal: true require 'puppeteer' module Html2rss class RequestService ## # Browserless.io strategy to request websites. # # Provide the WebSocket URL and your API token via environment variables: # - BROWSERLESS_IO_WEBSOCKET_URL # - BROWSERLESS_IO_API_TOKEN # # To use this strategy, you need to have a Browserless.io account or run a # local Browserless.io instance. # # @see https://www.browserless.io/ # # To run a local Browserless.io instance, you can use the following Docker command: # # ```sh # docker run \ # --rm \ # -p 3000:3000 \ # -e "CONCURRENT=10" \ # -e "TOKEN=6R0W53R135510" \ # ghcr.io/browserless/chromium # ``` # # When running locally, you can skip setting the environment variables, as above commands # are aligned with the default values. # @see https://github.com/browserless/browserless/pkgs/container/chromium class BrowserlessStrategy < Strategy # return [Response] def execute Puppeteer.connect(browser_ws_endpoint:) do |browser| PuppetCommander.new(ctx, browser).call ensure browser.disconnect end end def browser_ws_endpoint @browser_ws_endpoint ||= begin api_token = ENV.fetch('BROWSERLESS_IO_API_TOKEN', '6R0W53R135510') ws_url = ENV.fetch('BROWSERLESS_IO_WEBSOCKET_URL', 'ws://127.0.0.1:3000') "#{ws_url}?token=#{api_token}" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
html2rss-0.16.0 | lib/html2rss/request_service/browserless_strategy.rb |