-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dcaab20
commit 6f52701
Showing
1 changed file
with
6 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |