Created
September 5, 2011 06:49
-
-
Save oogali/1194262 to your computer and use it in GitHub Desktop.
Quick FCC ULS search
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'nokogiri' | |
require 'net/http' | |
require 'date' | |
def search(freq, state) | |
h = Net::HTTP.new 'wireless2.fcc.gov', 80 | |
resp, body = h.post('/UlsApp/UlsSearch/results.jsp', "fiUlsServiceSearchByType=300&ulsTowerNum=&feqSearchType=exact&fiFrequency=#{freq}&fiLowerFrequency=&fiUpperFrequency=&fiOwnerName=&fiUlsFRN=&fiCity=&ulsState=#{state.upcase}&fiUlsZipcode=&ulsCallSign=&statusAll=Y&ulsAuthTypeAll=Y&ulsDateType=&dateSearchType=+&ulsFromDate=&ulsToDate=#{Time.now.strftime('%m/%d/%Y').gsub('/', '%2F')}&fiRowsPerPage=50&ulsSortBy=uls_l_callsign++++++++++++++++&ulsOrderBy=ASC&x=42&y=10&hiddenForm=hiddenForm&jsValidated=true&searchType=ULN", { 'Referer' => 'http://wireless2.fcc.gov/UlsApp/UlsSearch/searchSite.jsp' }) | |
doc = Nokogiri::HTML body | |
results = doc.xpath('//table[@summary="License search results"]/tr[@valign="top"]').collect do |result| | |
num, callsign, name, frn, service, status, expires = result.xpath('td') | |
{ | |
:callsign => callsign.text.strip, | |
:name => name.text.strip, | |
:status => status.text.strip, | |
:expires => Date.parse(expires.text.strip) | |
} | |
end | |
end | |
if ARGV.length <= 0 | |
puts "#{__FILE__} <frequency> <2-letter state>" | |
exit | |
end | |
freq, state = ARGV[0], ARGV[1].upcase | |
puts | |
puts "*" * (freq.length + state.length + 7) | |
puts "* #{freq} (#{state}) *" | |
puts "*" * (freq.length + state.length + 7) | |
puts | |
puts "Callsign\tStatus\t\tLicensee\t\t\t\t\t\tExpires" | |
puts "-" * 98 | |
results = search(ARGV[0], ARGV[1]).sort{ |a,b| b[:expires] <=> a[:expires] } | |
if results and results.length > 0 | |
results.each do |result| | |
puts "#{result[:callsign].ljust(10)}\t#{result[:status].ljust(10)}\t#{result[:name].ljust(50)}\t#{result[:expires]}" | |
end | |
else | |
puts "(No matches found)" | |
end | |
puts | |
__END__ | |
marvin:~ oogali$ ./freqsearch.rb | |
./freqsearch.rb <frequency> <2-letter state> | |
marvin:~ oogali$ ./freqsearch.rb 455.1125 NY | |
***************** | |
* 455.1125 (NY) * | |
***************** | |
Callsign Status Licensee Expires | |
-------------------------------------------------------------------------------------------------- | |
KA88617 Canceled SPORTS RADIO GROUP, LLC 2014-08-01 | |
WZB718 Canceled SPORTS RADIO GROUP, LLC 2014-08-01 | |
KC25205 Active ANASTOS MEDIA GROUP, INC. 2014-06-01 | |
WQNA826 Active LLOYD LANE, INCORPORATED 2014-06-01 | |
KZH824 Active WTVD TELEVISION, LLC 2012-12-01 | |
KC23190 Canceled MEGA COMMUNICATIONS OF DAYTONA BEACH LICENSEE, LLC 2012-02-01 | |
KPK520 Active ABC, INC. 2007-08-01 | |
KPJ230 Canceled MEGA COMMUNICATIONS OF DAYTONA BEACH LICENSEE, LLC 2004-02-01 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment