Skip to content

Commit

Permalink
SL: add school ID (using the uuid); change phone to optional
Browse files Browse the repository at this point in the history
  • Loading branch information
cyroxx committed Dec 3, 2019
1 parent 0fa67c8 commit 395d8d3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions jedeschule/spiders/saarland.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ def parse(self, response):
details_url = f"https://www.saarland.de/schuldetails.htm?id={uuid}"
request = scrapy.Request(details_url, callback=self.parse_list)
request.meta['name'] = name.strip() if name else ""
request.meta['uuid'] = uuid
yield request

def parse_list(self, response):
school = response.css("body")
data = {'name': response.meta["name"],
data = {'id': f'SL-{response.meta["uuid"]}',
'name': response.meta["name"],
'data-url': response.url}

# All of the entries except for Homepage follow
Expand All @@ -46,8 +48,9 @@ def parse_list(self, response):
@staticmethod
def normalize(item):
zip, city = item['Stadt/Gemeinde'].split(', ')
phone = item.get('Telefon').split('\n')[0]
return School(name=item.get('name'),
phone = item.get('Telefon').split('\n')[0] if item.get('Telefon') else None
return School(id=item['id'],
name=item.get('name'),
phone=phone,
director=item.get('Schulleiter/in'),
website=item.get('Homepage'),
Expand Down

0 comments on commit 395d8d3

Please sign in to comment.