require 'json' data = JSON.parse(File.read('/Users/masui/ScrapboxData/masui-photos.json')) data['pages'].each { |page| title = page['title'] found = false url = '' page['lines'].each { |line| if line =~ /(http(s)?:\S+amazonaws\S+\/[0-9a-fA-F]{32}\.jpg)/i url = $1 end if line =~ /(#壁紙|\[壁紙\])/ found = true end } if found && url != '' url.sub!(/http:\/\/masui.org.s3.amazonaws.com/,"https://s3-ap-northeast-1.amazonaws.com/masui.org") puts "[#{url}]" end }