Skip to content

Commit

Permalink
немного отредактировал
Browse files Browse the repository at this point in the history
  • Loading branch information
s3rgeym committed Nov 9, 2024
1 parent c009800 commit 8baa2f1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 25 deletions.
16 changes: 8 additions & 8 deletions hh_applicant_tool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@


class BaseOperation(metaclass=ABCMeta):
def setup_parser(self, parser: argparse.ArgumentParser) -> None:
...
def setup_parser(self, parser: argparse.ArgumentParser) -> None: ...

@abstractmethod
def run(self, args: argparse.Namespace) -> None | int:
...
def run(self, args: argparse.Namespace) -> None | int: ...


OPERATIONS = "operations"
Expand All @@ -41,12 +39,16 @@ class Namespace(argparse.Namespace):

class HHApplicantTool:
"""Утилита для автоматизации действий соискателя на сайте hh.ru.
Описание, исходники и предложения: <https://github.com/s3rgeym/hh-applicant-tool>.
Исходники и предложения: <https://github.com/s3rgeym/hh-applicant-tool>
Группа поддержки: <https://t.me/vaitishniki>
"""

def create_parser(self) -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
description=self.__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument(
"-c",
Expand Down Expand Up @@ -82,9 +84,7 @@ def run(self, argv: Sequence[str] | None) -> None | int:
logger.setLevel(log_level)
handler = ColorHandler()
# [C] Critical Error Occurred
handler.setFormatter(
logging.Formatter("[%(levelname).1s] %(message)s")
)
handler.setFormatter(logging.Formatter("[%(levelname).1s] %(message)s"))
logger.addHandler(handler)
if args.run:
try:
Expand Down
54 changes: 37 additions & 17 deletions hh_applicant_tool/operations/apply_similar.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,22 @@ def run(self, args: Namespace) -> None:
page_min_interval, page_max_interval = args.page_interval

self._apply_similar(
api, resume_id, args.force_message, application_messages, apply_min_interval, apply_max_interval, page_min_interval, page_max_interval
api,
resume_id,
args.force_message,
application_messages,
apply_min_interval,
apply_max_interval,
page_min_interval,
page_max_interval,
)

def _get_vacancies(
self, api: ApiClient, resume_id: str, page_min_interval: float, page_max_interval: float
self,
api: ApiClient,
resume_id: str,
page_min_interval: float,
page_max_interval: float,
) -> list[VacancyItem]:
rv = []
per_page = 100
Expand Down Expand Up @@ -125,26 +136,35 @@ def _apply_similar(
page_max_interval: float,
) -> None:
item: VacancyItem
for item in self._get_vacancies(api, resume_id, page_min_interval, page_max_interval):
for item in self._get_vacancies(
api, resume_id, page_min_interval, page_max_interval
):
try:
if item["has_test"]:
print('Пропускаем тест', item["alternate_url"])
print("Пропускаем тест", item["alternate_url"])
continue

relations = item.get("relations", [])

# Там черезжопно нужно хеш отклика получать чтобы его отменить
# if "got_response" in relations:
# # Тупая пизда ее даже не рассматривала
# print(
# "Отменяем заявку чтобы отправить ее снова",
# item["alternate_url"],
# )
# api.delete(f"/negotiations/active/{item['id']}")
# elif relations:
if relations:
print("Пропускаем ответ на заявку", item["alternate_url"])
continue

relations = item.get('relations', [])

if 'got_response' in relations:
# Тупая пизда ее даже не рассматривала
print('Отменяем заявку чтобы отправить ее снова', item["alternate_url"])
api.delete(f"/negotiations/active/{item['id']}")
else relations:
print('Пропускаем ответ на зяавку', item["alternate_url"])
continue

# Задержка перед отправкой отклика
interval = random.uniform(apply_min_interval, apply_max_interval)
interval = random.uniform(
apply_min_interval, apply_max_interval
)
time.sleep(interval)

params = {
"resume_id": resume_id,
"vacancy_id": item["id"],
Expand All @@ -154,7 +174,7 @@ def _apply_similar(
else ""
),
}

res = api.post("/negotiations", params)
assert res == {}
print(
Expand Down

0 comments on commit 8baa2f1

Please sign in to comment.