Skip to content

Instantly share code, notes, and snippets.

@kd7lxl
Created July 25, 2010 20:16
Show Gist options
  • Save kd7lxl/489847 to your computer and use it in GitHub Desktop.
Save kd7lxl/489847 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import pprint
from HTMLParser import HTMLParser
from urllib2 import urlopen
class Spider(HTMLParser):
line = []
output = []
def __init__(self, url):
HTMLParser.__init__(self)
req = urlopen(url)
self.feed(req.read())
def handle_starttag(self, tag, attrs):
if tag == 'tr':
self.line = []
def handle_endtag(self, tag):
if tag == 'tr':
self.output.append(self.line)
def handle_data(self, data):
if data == 'Callsign':
self.output = []
self.line.append(data.strip())
spider = Spider('http://rotate.aprs2.net:14501/')
callsigns = []
for line in spider.output:
try:
if line[2] != 'Callsign':
callsigns.append(line[2])
except IndexError:
continue
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(callsigns)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment