Skip to content

Instantly share code, notes, and snippets.

Iain Barr ijmbarr

Block or report user

Report or block ijmbarr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View GEscraping
#Functions for scrapping UK general election results from http://www.politicsresources.net/area/uk/edates.htm.
#point "processAYear" at the index page for a year (e.g. "http://www.politicsresources.net/area/uk/ge50/")
#The function returns a list of dictionary objects representing the results for each constituency.
from bs4 import BeautifulSoup
import requests
def processAYear(url):
page = BeautifulSoup(requests.get(url).text)
tables = [x.get("href") for x in page.findAll("a") if x.get("href")[0] == "i"]
You can’t perform that action at this time.