Skip to content

Instantly share code, notes, and snippets.

@Elwell
Last active December 14, 2015 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Elwell/5137304 to your computer and use it in GitHub Desktop.
Save Elwell/5137304 to your computer and use it in GitHub Desktop.
Query to get VK6 callsigns from the ACMA
#!/usr/bin/python
# Script to gather callsigns from http://web.acma.gov.au/pls/radcom/register_search.search_dispatcher
import urllib2
import csv
from bs4 import BeautifulSoup
todo = None
base ='http://web.acma.gov.au'
url = base + '/pls/radcom/register_search.search_dispatcher'
post = 'pSEARCH_TYPE=Licences&pSUB_TYPE=Callsign&pEXACT_IND=begins+with&pQRY=VK6&SUBMIT=Go'
out = csv.writer(open('VK6.csv','w'))
runit = 1
while runit:
if todo:
data = urllib2.urlopen(base + todo).read()
else:
data = urllib2.urlopen(url,post).read()
#soup = BeautifulSoup(open('test1.html'))
soup = BeautifulSoup(data)
table = soup.find_all('table')[1]
for row in table.find_all('tr')[5:-6]:
line = []
for td in row.find_all('td'):
line.append(td.get_text().strip())
if td.a: # We want to pull the personID out of the table to look up address and other callsigns
href = str(td.a['href'])
if 'client' in href:
line.append(href.split('=')[1])
out.writerow(line)
print line
# do we have more to get?if soup.find('a',title='Next Page'):
link = soup.find('a',title='Next Page')
todo = str(link['href'])
print "Following to %s" % str(link['href'])
else:
runit = 0
print "Thats All Folks!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment