Sha256: 35dd03a3af27841cbfd3755ba04a1a098a933e6b33ea310e2344fd3c2bd15f95
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
#coding: utf-8 module Wombat module Property module Locators class Follow < Base def locate(context, page = nil) super do locate_nodes(context).flat_map do |node| retried = false begin # Certain erroneous pages contain http # links with relative href attribute, # while browsers actually use them as # absolute. # So, let wombat try that approach when # loading relative link fails. # target_page = page.click node context = target_page.parser filter_properties(context, page) rescue Mechanize::ResponseCodeError => e # Either the page is unavailable, or # the link is mistakenly relative # raise e if retried # Give it a try first time href = node.attributes && node.attributes["href"] if href.respond_to? :value href.value = '/' + href.value unless href.value.start_with? '/' retried = true retry else raise e end end end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wombat-2.4.0 | lib/wombat/property/locators/follow.rb |
wombat-2.3.0 | lib/wombat/property/locators/follow.rb |