From 30d8fbf98ace6b6cd15b21519025b7c6448a334d Mon Sep 17 00:00:00 2001 From: milk1000cc Date: Fri, 28 Jun 2024 16:14:03 +0900 Subject: [PATCH] fix: support ferrum v0.15 with proxy --- lib/vessel/driver/ferrum/driver.rb | 2 +- lib/vessel/driver/ferrum/page.rb | 5 +++-- vessel.gemspec | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/vessel/driver/ferrum/driver.rb b/lib/vessel/driver/ferrum/driver.rb index 8e924d5..e068e2b 100644 --- a/lib/vessel/driver/ferrum/driver.rb +++ b/lib/vessel/driver/ferrum/driver.rb @@ -35,7 +35,7 @@ def create_page(proxy: nil) options = {} options.merge!(proxy: proxy) if proxy page = browser.create_page(**options) - Page.new(page) + Page.new(page, context: browser.contexts[page.context_id]) end end end diff --git a/lib/vessel/driver/ferrum/page.rb b/lib/vessel/driver/ferrum/page.rb index 843f389..a2d0eb3 100644 --- a/lib/vessel/driver/ferrum/page.rb +++ b/lib/vessel/driver/ferrum/page.rb @@ -11,13 +11,14 @@ class Page < Page attr_reader :page - def initialize(page) + def initialize(page, context:) super() @page = page + @context = context end def close - page.context.dispose if page.use_proxy? + @context.dispose if page.use_proxy? page.close end diff --git a/vessel.gemspec b/vessel.gemspec index 2c5c45e..58e68d2 100644 --- a/vessel.gemspec +++ b/vessel.gemspec @@ -27,7 +27,7 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 2.7.0" - s.add_runtime_dependency "ferrum", "~> 0.12" + s.add_runtime_dependency "ferrum", ">= 0.15" s.add_runtime_dependency "mechanize", ">= 2.8.5" s.add_runtime_dependency "nokogiri", "~> 1.13" s.add_runtime_dependency "thor", "~> 1.2"