Created
July 25, 2010 20:16
-
-
Save kd7lxl/489847 to your computer and use it in GitHub Desktop.
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 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