Created
September 14, 2020 15:15
-
-
Save theoctober19th/f9a429c6265363785ad5ce135b1fabec to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#Duration | |
duration_options = response.css('div.field-name-field-length-of-program').xpath('./descendant::div[contains(@class,"field-item")]/text() | ./descendant::div[contains(@class,"field-item")]/p/text()').getall() | |
fulltime, parttime = False, False | |
try: | |
duration_text = duration_options[0].strip() | |
except: | |
duration_text = '' | |
for duration_option in duration_options: | |
if 'full' in duration_option.strip().lower(): | |
duration_text = duration_option.strip() | |
fulltime = True | |
if 'part' in duration_option.strip().lower(): | |
parttime = True | |
duration_regex = re.compile(r'\d{1,3}\s(months?)', re.IGNORECASE) | |
duration_match = re.search(duration_regex, duration_text) | |
if duration_match: | |
item['duration'] = duration_match.group() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment