Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Scrap Charter Members lines for electronic voting
# Simple script to take from the OSGeo wiki the data to
# print on the console the lines to be used on the
# electronic voting system to produce meaninful
# questions with links and info.
from BeautifulSoup import BeautifulSoup
import urllib
nominations_url = ''
response = urllib.urlopen(nominations_url)
html_doc =
soup = BeautifulSoup(html_doc)
table = soup.findAll('table','wikitable')[0]
for tr in table.findAll('tr')[1:]:
tds = tr.findAll('td')
num = tds[0].span.string.strip().encode('utf-8')
aName = tds[1].findAll('a')
if len(aName)>0:
name = aName[0].string.strip().encode('utf-8')
name = tds[1].findAll('i')[0].string.strip().encode('utf-8')
country = tds[2].findAll(['i'])[0].string
nabble_name = '+'.join([ 'message%3A{}'.format(urllib.quote_plus(word)) for word in name.split()])
nabble_search = '<a href="{}+author%3A%22Jorge+Sanz%22&days=30">discussion</a>'.format(nabble_name)
print "<a href=\"{}#{}\">{}</a> - {} - {}".format(nominations_url,num,name,country,nabble_search)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment