Last active
August 8, 2017 17:32
-
-
Save mangege/755536f08202a16ff5bee029571b5e99 to your computer and use it in GitHub Desktop.
检查有效的联通缓存服务器ip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'uri' | |
require 'net/http' | |
require 'timeout' | |
def check_server(ip) | |
uri = URI('http://ip.mangege.com/') | |
Timeout::timeout(3) do | |
Net::HTTP.start(ip, 80) do |http| | |
request = Net::HTTP::Get.new uri | |
response = http.request request | |
puts ip if response.body.include?(ip) | |
end | |
end | |
rescue | |
end | |
(1..254).each do |i| | |
check_server("120.52.72.#{i}") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
120.52.72.19
120.52.72.20
120.52.72.21
120.52.72.22
120.52.72.23
120.52.72.24
120.52.72.47
120.52.72.48
120.52.72.52
120.52.72.53
120.52.72.54
120.52.72.55
120.52.72.56
120.52.72.58
120.52.72.59