#!/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) end end end pp ensen