1
- import re
2
-
3
1
from utils import CanadianPerson as Person
4
2
from utils import CanadianScraper
5
3
6
4
COUNCIL_PAGE = "https://www.ville.sainte-anne-de-bellevue.qc.ca/fr/199/elus-municipaux"
7
5
6
+
8
7
class SainteAnneDeBellevuePersonScraper (CanadianScraper ):
9
8
def scrape (self ):
10
9
def decode_email (e ):
@@ -20,8 +19,8 @@ def decode_email(e):
20
19
21
20
councillors = page .xpath ('//div[@class="col-md-12"]' )[0 ]
22
21
assert len (councillors ), "No councillors found"
23
-
24
- roles_and_districts = councillors .xpath (' .//h2/text()' )
22
+
23
+ roles_and_districts = councillors .xpath (" .//h2/text()" )
25
24
roles = []
26
25
districts = []
27
26
names = []
@@ -32,30 +31,22 @@ def decode_email(e):
32
31
role_and_district = role .split ()
33
32
34
33
roles .append (role_and_district [0 ])
35
-
34
+
36
35
if len (role_and_district ) == 1 :
37
36
districts .append ("Sainte-Anne-de-Bellevue" )
38
37
else :
39
38
districts .append ("District " + role_and_district [2 ])
40
-
39
+
41
40
# Fill in contact info via p tags.
42
41
contact_info = councillors .xpath ('.//p[a[contains(@href, "@")]]' )
43
42
for contact in contact_info :
44
43
contact = contact .text_content ().split ()
45
- print (contact )
46
- input ()
47
44
name = " " .join (contact [:2 ])
48
45
names .append (name )
49
-
46
+
50
47
email = contact [3 ]
51
48
email = email .replace ("Président" , "" )
52
49
emails .append (email )
53
-
54
- print (roles )
55
- print (districts )
56
- print (names )
57
- print (emails )
58
- input ()
59
50
60
51
assert len (roles ) == len (districts ) == len (names ) == len (emails ), "Lists are not of equal length"
61
52
for i in range (len (roles )):
0 commit comments