#!/usr/local/bin/ruby area = ["https://www.chintai.net/rent/hokkaido/ensen/", "https://www.chintai.net/rent/aomori/ensen/", "https://www.chintai.net/rent/iwate/ensen/"] =begin , "https://www.chintai.net/rent/miyagi/ensen/", "https://www.chintai.net/rent/akita/ensen/", "https://www.chintai.net/rent/yamagata/ensen/", "https://www.chintai.net/rent/fukushima/ensen/", "https://www.chintai.net/rent/tokyo/ensen/", "https://www.chintai.net/rent/kanagawa/ensen/", "https://www.chintai.net/rent/saitama/ensen/", "https://www.chintai.net/rent/chiba/ensen/", "https://www.chintai.net/rent/ibaragi/ensen/", "https://www.chintai.net/rent/tochigi/ensen/", "https://www.chintai.net/rent/gunma/ensen/", "https://www.chintai.net/rent/nagano/ensen/", "https://www.chintai.net/rent/toyama/ensen/", "https://www.chintai.net/rent/ishikawa/ensen/", "https://www.chintai.net/rent/fukui/ensen/", "https://www.chintai.net/rent/niigata/ensen/", "https://www.chintai.net/rent/yamanashi/ensen/", "https://www.chintai.net/rent/gifu/ensen/", "https://www.chintai.net/rent/sizuoka/ensen/", "https://www.chintai.net/rent/mie/ensen/", "https://www.chintai.net/rent/aichi/ensen/", "https://www.chintai.net/rent/osaka/ensen/", "https://www.chintai.net/rent/hyogo/ensen/", "https://www.chintai.net/rent/kyoto/ensen/", "https://www.chintai.net/rent/shiga/ensen/", "https://www.chintai.net/rent/nara/ensen/", "https://www.chintai.net/rent/wakayama/ensen/", "https://www.chintai.net/rent/tottori/ensen/", "https://www.chintai.net/rent/simane/ensen/", "https://www.chintai.net/rent/okayama/ensen/", "https://www.chintai.net/rent/hiroshima/ensen/", "https://www.chintai.net/rent/yamaguchi/ensen/", "https://www.chintai.net/rent/tokushima/ensen/", "https://www.chintai.net/rent/kagawa/ensen/", "https://www.chintai.net/rent/ehime/ensen/", "https://www.chintai.net/rent/kouchi/ensen/", "https://www.chintai.net/rent/fukuoka/ensen/", "https://www.chintai.net/rent/saga/ensen/", "https://www.chintai.net/rent/nagasaki/ensen/", "https://www.chintai.net/rent/kumamoto/ensen/", "https://www.chintai.net/rent/ooita/ensen/", "https://www.chintai.net/rent/miyazaki/ensen/", "https://www.chintai.net/rent/kagoshima/ensen/", "https://www.chintai.net/rent/okinawa/ensen/"] =end require 'open-uri' require "pp" #area = ["https://www.chintai.net/rent/hokkaido/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_url