Skip to content

Instantly share code, notes, and snippets.

@mattfoster
Created February 6, 2009 12:07
Show Gist options
  • Save mattfoster/59370 to your computer and use it in GitHub Desktop.
Save mattfoster/59370 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# Grab the width of the macheist bar.
# Run using:
# while true; do sleep 60; python heist_parse.py >> heist_countdown; done
import urllib2
import re
import time
from BeautifulSoup import BeautifulSoup
url='http://mainframe.macheist.com/'
page = urllib2.urlopen(url)
page = ''.join(page.readlines())
soup = BeautifulSoup(page)
desc = soup.fetch('div',{'class':'progress'})[0]['style']
print time.time(), '\t', re.search(r'^width: (.*)px$', desc).group(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment