#!/usr/local/bin/ruby require 'open-uri' require "pp" =begin sio = OpenURI.open_uri("https://www.chintai.net/rent/") area = [] sio.each_line do |l| if l =~ %r|rent/[a-z]+/ensen| short_url = l.slice(%r|(rent/[a-z]+/ensen)|, 1) area << "https://www.chintai.net/#{short_url}" end end pp area =end =begin area = ["https://www.chintai.net/rent/hokkaido/ensen", "https://www.chintai.net/rent/aomori/ensen", "https://www.chintai.net/rent/iwate/ensen", "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"] pp area https://www.chintai.net/tokyo/ensen/101001/rent/ https://www.chintai.net/tokyo/ensen/101001/rent/ https://www.chintai.net/okinawa/ensen/B02063/rent/ =end area = ["https://www.chintai.net/rent/hokkaido/ensen"] ensen = [] area.each do |l| sio = OpenURI.open_uri(l) sio.each_line do |l| if l =~ %r|/ensen/\S+/rent/| ensen << l.slice(%r|(https://www.chintai.net/tokyo/ensen/\S+/rent/)|, 1) end end end pp ensen