Skip to content

Commit b6d5cd8

Browse files
authored
fix:correct LinkedIn logger naming (#291)
* fix:correct LinkedIn logger naming * add:linkedin description plain format
1 parent 84ed670 commit b6d5cd8

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

jobspy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def scrape_site(site: Site) -> Tuple[str, JobResponse]:
107107
scraped_data: JobResponse = scraper.scrape(scraper_input)
108108
cap_name = site.value.capitalize()
109109
site_name = "ZipRecruiter" if cap_name == "Zip_recruiter" else cap_name
110+
site_name = "LinkedIn" if cap_name == "Linkedin" else cap_name
110111
create_logger(site_name).info(f"finished scraping")
111112
return site.value, scraped_data
112113

jobspy/linkedin/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
extract_emails_from_text,
3636
currency_parser,
3737
markdown_converter,
38+
plain_converter,
3839
create_session,
3940
remove_attributes,
4041
create_logger,
@@ -267,7 +268,8 @@ def _get_job_details(self, job_id: str) -> dict:
267268
description = div_content.prettify(formatter="html")
268269
if self.scraper_input.description_format == DescriptionFormat.MARKDOWN:
269270
description = markdown_converter(description)
270-
271+
elif self.scraper_input.description_format == DescriptionFormat.PLAIN:
272+
description = plain_converter(description)
271273
h3_tag = soup.find(
272274
"h3", text=lambda text: text and "Job function" in text.strip()
273275
)

jobspy/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class Compensation(BaseModel):
234234
class DescriptionFormat(Enum):
235235
MARKDOWN = "markdown"
236236
HTML = "html"
237-
237+
PLAIN = "plain"
238238

239239
class JobPost(BaseModel):
240240
id: str | None = None

jobspy/util.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,15 @@ def markdown_converter(description_html: str):
157157
markdown = md(description_html)
158158
return markdown.strip()
159159

160+
def plain_converter(decription_html:str):
161+
from bs4 import BeautifulSoup
162+
if decription_html is None:
163+
return None
164+
soup = BeautifulSoup(decription_html, "html.parser")
165+
text = soup.get_text(separator=" ")
166+
text = re.sub(r'\s+',' ',text)
167+
return text.strip()
168+
160169

161170
def extract_emails_from_text(text: str) -> list[str] | None:
162171
if not text:

0 commit comments

Comments
 (0)