Fix chi_ssa_61
@@ -19,11 +19,13 @@ class ChiSsa61Spider(CityScrapersSpider):
def parse(self, response):
"""Parse meetings on upcoming and minutes pages"""
self._validate_location(response)
- for item in response.xpath('//div[@rel="1"]/ul/li/strong'):
- text = item.xpath('./text()').extract_first()
+ for item in response.css(".about-tabs .active li"):
+ text = " ".join(item.css("*::text").extract()).strip()
if not re.search(r"[ pam\.]{2,5}", text):
continue
start = self._parse_start(text)
+ if not start:
+ continue
meeting = Meeting(
title="Commission",
description='',
@@ -46,7 +48,6 @@ class ChiSsa61Spider(CityScrapersSpider):
"""
date_match = re.search(r'[a-zA-Z]{3,9} \d{1,2}([a-z,]{1,3})? \d{4}', text)
time_match = re.search(r'\d{1,2}:\d{2}[ pam\.]{2,5}', text)
- if date_match:
try:
date_str = re.sub(
r'(?<=\d)[a-z]{2}',
@@ -54,17 +55,16 @@ class ChiSsa61Spider(CityScrapersSpider):
date_match.group().replace(',', ''),
)
dt = datetime.strptime(date_str, '%B %d %Y').date()
- except ValueError:
- dt = None
+ except (AttributeError, ValueError):
+ return
if time_match:
time_str = time_match.group().replace('.', '').replace(' ', '')
tm = datetime.strptime(time_str, '%I:%M%p').time()
else:
tm = time(10)
- if dt:
return datetime.combine(dt, tm)
def _validate_location(self, response):
- xpath_test = "//*[@id=\"about\"]/div/div[2]/div/div[2]/div[1]/p[10]/text()"
- if "Polsky Center for Innovation" not in " ".join(response.xpath(xpath_test).extract()):
+ about_text = re.sub(r"\s+", " ", " ".join(response.css(".about-tabs *::text").extract()))
+ if "Polsky Center" not in about_text:
raise ValueError("Meeting location has changed")
