#!/usr/local/bin/ruby require 'open-uri' require "pp" area = ["https://www.chintai.net/rent/hokkaido/ensen/"] ensen = [] ensen_url = [] area.each do |l| sio = OpenURI.open_uri(l) sio.each_line do |l| if l =~ %r|/ensen/\S+/rent/| ensen << l.slice(%r|(/\S+/ensen/\S+/rent/)|, 1) # ensen_url << "https://www.chintai.net#{ensen}" end end end pp ensen