-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5353e6
commit 90fa4a4
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import re | ||
import tls_client | ||
|
||
|
||
def count_urgent_words(description: str) -> int: | ||
""" | ||
Count the number of urgent words or phrases in a job description. | ||
""" | ||
urgent_patterns = re.compile( | ||
r"\burgen(t|cy)|\bimmediate(ly)?\b|start asap|\bhiring (now|immediate(ly)?)\b", | ||
re.IGNORECASE, | ||
) | ||
matches = re.findall(urgent_patterns, description) | ||
count = len(matches) | ||
|
||
return count | ||
|
||
|
||
def extract_emails_from_text(text: str) -> list[str] | None: | ||
if not text: | ||
return None | ||
email_regex = re.compile(r"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}") | ||
return email_regex.findall(text) | ||
|
||
|
||
def create_session(proxy: str | None = None): | ||
""" | ||
Creates a tls client session | ||
:return: A session object with or without proxies. | ||
""" | ||
session = tls_client.Session( | ||
client_identifier="chrome112", | ||
random_tls_extension_order=True, | ||
) | ||
session.proxies = proxy | ||
# TODO multiple proxies | ||
# if self.proxies: | ||
# session.proxies = { | ||
# "http": random.choice(self.proxies), | ||
# "https": random.choice(self.proxies), | ||
# } | ||
|
||
return session |