"""Scrapes information from your watchlist on the Noisebridge wiki."""

from scrape import *

# Go to the home page
s.go('http://noisebridge.net/')

# Navigate to the login page
s.follow(iregex('log in'))

# Submit the login form
f = s.doc.first('form', name='userlogin')
button = f.firsttag('input', name='wpLoginAttempt')
s.submit(button, wpName='scrape', wpPassword='foo')

# Go to the watchlist
s.follow(iregex('my watchlist'))

# Print out some items
for item in s.doc.first('div', id='mw-content-text').all('li'):
    if item.all('a'):
        title = item.all('a')[2].text
        user = item.first('a', class_='mw-userlink').text
        print '"%s" edited by %s' % (title, user)
