def test_normalize_spacing(self): raw_text = "game_start_utc country tournament host_team guest_team ratio_1 ratio_X ratio_2" normalized_text = "game_start_utc country tournament host_team guest_team ratio_1 ratio_X ratio_2" self.assertEqual(text_tool.normalize_spacing(raw_text), normalized_text) raw_text = """a b \nc\td\ne\tf""" self.assertEqual("a b c d e f", text_tool.normalize_spacing(raw_text))
def get_posted_time(cls, tag): posted_tags = tag.select(":scope span[data-automation='jobListingDate']") if posted_tags: posted_text = normalize_spacing(posted_tags[0].get_text().strip()) posted_timedelta = TimedeltaParser.parse(posted_text) return utc_moment() - posted_timedelta return None
def _choose_value(self, value: str): _log.debug("selecting date-posted value: '%s'", value) visible_labels = [] for label in self._filter_value_label: label_text = normalize_spacing(label.text.strip()) if value.lower() in label_text.lower(): label_input = label.parent_element.find_element_by_tag_name( "input") self._driver.execute_script("arguments[0].click();", label_input.wrapped_element) return else: visible_labels.append(label_text) _log.warning("visible date-posted filter values: %s", visible_labels) raise RuntimeError("Could not click Date-Posted filter value!", value, visible_labels)
def get_company(cls, tag): company_tags = tag.select(":scope a[data-automation='jobCompany']") return normalize_spacing(company_tags[0].get_text().strip()) if company_tags else None
def get_salary(cls, tag): salary_tags = tag.select(":scope span[data-automation='jobSalary']") return normalize_spacing(salary_tags[0].get_text().strip()) if salary_tags else None
def get_title(cls, tag): title_tags = tag.select(":scope h1 > a") return normalize_spacing(title_tags[0].get_text().strip()) if title_tags else None
def get_sub_classification(cls, tag): sub_classification_tags = tag.select(":scope a[data-automation='jobSubClassification']") return normalize_spacing(sub_classification_tags[0].get_text().strip()) if sub_classification_tags else None
def get_area(cls, tag): area_tags = tag.select(":scope a[data-automation='jobArea']") return normalize_spacing(area_tags[0].get_text().strip()) if area_tags else None
def get_location(cls, tag): location_tags = tag.select(":scope a[data-automation='jobLocation']") return normalize_spacing(location_tags[0].get_text().strip()) if location_tags else None
def get_company(cls, tag): company_tags = tag.select(":scope h4.result-card__subtitle") return normalize_spacing( company_tags[0].get_text().strip()) if company_tags else None
def get_title(cls, tag): title_tags = tag.select(":scope h3.job-result-card__title") return normalize_spacing( title_tags[0].get_text().strip()) if title_tags else None
def get_location(cls, tag): location_tags = tag.select(":scope span.job-result-card__location") return normalize_spacing( location_tags[0].get_text().strip()) if location_tags else None