解析单条职位数据
(self, raw_job: dict)
| 18 | } |
| 19 | |
| 20 | def parse(self, raw_job: dict) -> dict: |
| 21 | """解析单条职位数据""" |
| 22 | source = raw_job["_source"] |
| 23 | |
| 24 | return { |
| 25 | "id": source.get("id"), |
| 26 | "title": source.get("title", "N/A"), |
| 27 | "company": source.get("company", "N/A"), |
| 28 | "category": source.get("category_name", "N/A"), |
| 29 | "location": self._format_location(source.get("locations")), |
| 30 | "position_type": self.POSITION_TYPES.get( |
| 31 | source.get("position_type", "ft"), "Full-time" |
| 32 | ), |
| 33 | "salary": self._format_salary(source), |
| 34 | "experience": self.EXPERIENCE_MAP.get( |
| 35 | source.get("experience_level", ""), "Not specified" |
| 36 | ), |
| 37 | "tags": source.get("tags", []) or [], |
| 38 | "description": self._clean_html(source.get("description", "")), |
| 39 | "apply_url": source.get("apply_url", ""), |
| 40 | "pub_date": self._format_date(source.get("pub_date")), |
| 41 | } |
| 42 | |
| 43 | def _format_location(self, locations: list) -> str: |
| 44 | """格式化地点""" |
no test coverage detected