root = html_parse(html)
divs = get_elem(root, 'div')
divdetail = divs[3]
-
+ #print_idented_tree(divdetail, 0)
info_raw = {}
section = u''
boldtext = u''
continue
if isinstance(node, Tag) and node.name == 'h2':
if boldtext or text:
- info_raw[section][boldtext] = text
+ if not section:
+ print >> sys.stderr, "WARNING: section is empty for setting", boldtext, "=", text
+ else:
+ info_raw[section][boldtext] = text
boldtext = text = u''
section = get_inner_text(node)
info_raw[section] = {}
boldtext = text = u''
elif isinstance(node, Tag) and node.name == 'b':
if boldtext or text:
- info_raw[section][boldtext] = text
+ if not section:
+ print >> sys.stderr, "WARNING: section is empty for setting", boldtext, "=", text
+ else:
+ info_raw[section][boldtext] = text
boldtext = text = u''
boldtext = get_inner_text(node)
else:
info_raw = get_raw_summary(html)
info = qualify_summary(info_raw)
- #pprint(info)
+ pprint(info)
assert info['mmsi'] == mmsi
latlong = get_merged_leaf_content(line[5])
latlong = latlong.replace(u'\xa0', u'').strip()
if latlong:
- lon, lat = latlong.split(' ')
+ lat, lon = latlong.split(' ')
show_on_map = line[8]
assert get_merged_leaf_content(show_on_map).strip() == 'Show on Map'
cog = int(course*AIS_COG_SCALE)
heading = AIS_NO_HEADING
source = 'MTWW'
+ print strmmsi, timestamp, status, rot, sog, latitude, longitude, cog, heading, source
add_nmea1(strmmsi, timestamp, status, rot, sog, latitude, longitude, cog, heading, source)
import_track(mmsi, dt, isodt)
cog = int(info['course'])*AIS_COG_SCALE
heading = AIS_NO_HEADING
source = 'MTTR'
- #print datetime.utcfromtimestamp(timestamp),
- #for i in strmmsi, timestamp, status, rot, sog, latitude, longitude, cog, heading, source:
- # print repr(i),
- #print
+ print datetime.utcfromtimestamp(timestamp),
+ for i in strmmsi, timestamp, status, rot, sog, latitude, longitude, cog, heading, source:
+ print repr(i),
+ print
add_nmea1(strmmsi, timestamp, status, rot, sog, latitude, longitude, cog, heading, source)
#dbcommit()