<commit_before>from pupa.scrape import Scraper

from utils import lxmlize, CanadianLegislator as Legislator
import re

COUNCIL_PAGE = 'http://www.countygp.ab.ca/EN/main/government/council.html'


class GrandePrairieCountyNo1PersonScraper(Scraper):

  # @todo The Reeve is also a Councillor.
  def get_people(self):
    page = lxmlize(COUNCIL_PAGE)

    councillors = page.xpath('//table[@class="table-plain"]/tbody/tr/td[2]')
    for councillor in councillors:
      name = councillor.xpath('./h2')[0].text_content().split('Division')[0]
      district = re.findall(r'(Division [0-9])', councillor.xpath('./h2')[0].text_content())[0]

      p = Legislator(name=name, post_id=district, role='Councillor')
      p.add_source(COUNCIL_PAGE)<commit_msg>ca_ab_grande_prairie_county_no_1: add Reeve post<commit_after>from pupa.scrape import Scraper

from utils import lxmlize, CanadianLegislator as Legislator
import re

COUNCIL_PAGE = 'http://www.countygp.ab.ca/EN/main/government/council.html'
REEVE_URL = 'http://www.countygp.ab.ca/EN/main/government/council/reeve-message.html'


class GrandePrairieCountyNo1PersonScraper(Scraper):

  # @todo The Reeve is also a Councillor.
  def get_people(self):
    reeve_page = lxmlize(REEVE_URL)
    reeve_name = reeve_page.xpath('string(//b)').split(',')[0]

    page = lxmlize(COUNCIL_PAGE)

    councillors = page.xpath('//table[@class="table-plain"]/tbody/tr/td[2]')
    for councillor in councillors:
      name = councillor.xpath('./h2')[0].text_content().split(
          'Division')[0].strip()
      district = re.findall(r'(Division [0-9])', councillor.xpath('./h2')[0].text_content())[0]

      p = Legislator(name=name, post_id=district, role='Councillor')
      if name == reeve_name:
        p.add_committee_membership('Grande Prairie County No. 1', role='Reeve')
      p.add_source(COUNCIL_PAGE)
{'fraction_non_alphanumeric': 0.14959349593495935, 'fraction_numerical': 0.012466124661246613, 'mean_word_length': 4.526946107784431, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4880609', 'n_tokens_mistral': 736, 'n_tokens_neox': 693, 'n_words': 108}