Skip to content

Commit

Permalink
Fixed Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
samJMA committed Oct 29, 2024
1 parent 707e503 commit ca587f3
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions ca_qc_montreal_est/people.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
from utils import CanadianPerson as Person
from utils import CanadianScraper

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


COUNCIL_PAGE = "http://ville.montreal-est.qc.ca/vie-democratique/conseil-municipal/"
class MontrealEstPersonScraper(CanadianScraper):
def scrape(self):
page = self.lxmlize(COUNCIL_PAGE)
councillors = page.xpath("//div[contains(@id, 'membres-conseil-block_')]")
councillors = page.xpath('//div[contains (@class, "membreimg text-center membres-conseil")]//div//div[@class="col-lg-6"]')
assert len(councillors), "No councillors found"
for councillor in councillors:
name, role_district = councillor.xpath(".//span[@class='h3 d-block']")[0].text_content().split(" – ", 1)
name = councillor.xpath('.//div[@class="bg-trans-gris"]/span/text()')[0]

if "Maire" in role_district:
if "Maire" in name or "Mairesse" in name:
name = name.split(" ", 2)[:2]
name = " ".join(name)
district = "Montréal-Est"
role = "Maire"
else:
district = f"District {role_district[-1]}"
name, district = name.split(" ", 2)[:2], "District " + name.split(" ")[-1]
name = " ".join(name)
role = "Conseiller"

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

0 comments on commit ca587f3

Please sign in to comment.