Sha256: c615608db2d3e94d7d0f45063fb314175a7733d927a4c5986cb9e820ff163655
Contents?: true
Size: 681 Bytes
Versions: 2
Compression:
Stored size: 681 Bytes
Contents
# rubocop: disable Security/Open require "open-uri" require "uri" require "nokogiri" URL = URI("https://www.soumu.go.jp/main_sosiki/joho_tsusin/top/tel_number/number_shitei.html") html = URI.open(URL.to_s, &:read).force_encoding("cp932") doc = Nokogiri.parse(html) xls_urls = [] doc.css("h3").find {|h3| h3.text.include?("固定電話の電話番号") }.parent.css("a").each do |a| next unless a["href"] =~ /\.xls/ xls_urls << (URL + a["href"]).to_s end xls_urls.each do |url| basename = url.gsub(%r(.*/), "") dest = "#{__dir__}/../tmp/xls/#{basename}" warn "Download #{url} to #{dest}" File.write(dest, URI.open(url, &:read)) end # rubocop: enable Security/Open
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
phonenumber_jp-0.1.4 | scripts/xls_downloader.rb |
phonenumber_jp-0.1.3 | scripts/xls_downloader.rb |