Skip to content

Commit

Permalink
Update Montreal Est scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
rafe-murray committed Jun 5, 2024
1 parent dcaab20 commit 6f52701
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions ca_qc_montreal_est/people.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
from utils import CanadianPerson as Person
from utils import CanadianScraper

COUNCIL_PAGE = "http://ville.montreal-est.qc.ca/la-ville/conseil-municipal/conseils-municipaux/"
COUNCIL_PAGE = "https://ville.montreal-est.qc.ca/vie-democratique/conseil-municipal/"


class MontrealEstPersonScraper(CanadianScraper):
def scrape(self):
page = self.lxmlize(COUNCIL_PAGE)

councillors = page.xpath("//table")
councillors = page.xpath("//div[contains(@id, 'membres-conseil-block_')]")
assert len(councillors), "No councillors found"
for councillor in councillors:
name = councillor.xpath(".//h3")[0].text_content()
name, role_district = councillor.xpath(".//span[@class='h3 d-block']")[0].text_content().split(" – ", 1)

if "maire" in name:
name = name.split(" ", 2)[-1]
if "Maire" in role_district:
district = "Montréal-Est"
role = "Maire"
else:
district = "District {}".format(councillor.xpath(".//h3")[1].text_content()[-1])
district = "District {}".format(role_district[-1])
role = "Conseiller"

p = Person(primary_org="legislature", name=name, district=district, role=role)
p.image = councillor.xpath(".//@src")[0]
p.image = councillor.xpath(".//@data-lazy-src")[0]
p.add_contact("email", self.get_email(councillor))
p.add_source(COUNCIL_PAGE)
yield p

0 comments on commit 6f52701

Please sign in to comment.