Skip to content

Instantly share code, notes, and snippets.

@uranusjr
Created December 24, 2011 16:26
Show Gist options
  • Save uranusjr/1517714 to your computer and use it in GitHub Desktop.
Save uranusjr/1517714 to your computer and use it in GitHub Desktop.
f = open('MOON PHASE - ANIME.html', 'r')
o = open('output.txt', 'w')
line = True
while line:
line = f.readline().strip()
if line == '<tr>':
line = f.readline().strip() # Date cell
try:
date = line.split('>', 2)[2].split('<', 1)[0]
line = f.readline().strip() # Title cell
title = line.split('>', 3)[3].split('<', 1)[0]
url = line.split('href="', 1)[1].split('"', 1)[0]
output = date + ' ' + title + '\n' + url + '\n\n'
o.write(output)
except IndexError: # Wrong format, can't split correctly
pass
f.close()
o.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment