Skip to content

Instantly share code, notes, and snippets.

View martinth's full-sized avatar

Martin Thurau martinth

View GitHub Profile
@martinth
martinth / assertion_hook.py
Created August 8, 2011 21:24
A sample exception hook, that prints useful information if an AssertionError occures
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os.path
import pprint
sys._old_excepthook = sys.excepthook
def assert_hook(exc_type, exception, traceback):
@martinth
martinth / mde_login.py
Created August 3, 2011 22:23
mode.de login script
# -*- coding: utf-8 -*-
import cookielib
from urllib2 import HTTPCookieProcessor, build_opener
from urllib import urlencode
from BeautifulSoup import BeautifulSoup
# the login data
login_data = {
'login_username': u'USERNAME',
'login_password': u'PASSWORD',
from urllib2 import urlopen
from BeautifulSoup import BeautifulSoup
data = urlopen('''http://www.hydro.eaufrance.fr/stations/O7502510&procedure=tousmois''').read()
soup = BeautifulSoup(data)
table = soup.find('table', {'summary': "valeurs mensuelles et annuelles"})
for tr in table.findAll('tr'):
line = []
for td in tr.findAll('td'):
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.awt.AWTException;
public class KeyPresser {
public static void main(String[] args) {
int delay = 0;
try {