Skip to content

Instantly share code, notes, and snippets.

Embed
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 = 'http://wiki.osgeo.org/wiki/New_Member_Nominations_2014'
response = urllib.urlopen(nominations_url)
html_doc = response.read()
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')
else:
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="http://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=search_page&node=3842115&query={}+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
You can’t perform that action at this time.