added resume upload
This commit is contained in:
parent
40cf3e4d34
commit
d9ffc7542c
1 changed files with 62 additions and 76 deletions
|
|
@ -1,21 +1,13 @@
|
|||
<<<<<<< HEAD
|
||||
from typing import Dict, List
|
||||
from linkedin_api import Linkedin
|
||||
from typing import Optional, Union, Literal
|
||||
from urllib.parse import quote, urlencode, parse_qs, urlparse
|
||||
=======
|
||||
>>>>>>> upstream/v3
|
||||
import logging
|
||||
from typing import Dict, List
|
||||
from typing import Optional, Union, Literal
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from linkedin_api import Linkedin
|
||||
import json
|
||||
|
||||
# set log to all debug
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
class LinkedInEvolvedAPI(Linkedin):
|
||||
already_applied_jobs: List[str] = []
|
||||
|
||||
|
|
@ -23,44 +15,44 @@ class LinkedInEvolvedAPI(Linkedin):
|
|||
super().__init__(username, password)
|
||||
|
||||
def search_jobs(
|
||||
self,
|
||||
keywords: Optional[str] = None,
|
||||
companies: Optional[List[str]] = None,
|
||||
experience: Optional[
|
||||
List[
|
||||
Union[
|
||||
Literal["1"],
|
||||
Literal["2"],
|
||||
Literal["3"],
|
||||
Literal["4"],
|
||||
Literal["5"],
|
||||
Literal["6"],
|
||||
]
|
||||
self,
|
||||
keywords: Optional[str] = None,
|
||||
companies: Optional[List[str]] = None,
|
||||
experience: Optional[
|
||||
List[
|
||||
Union[
|
||||
Literal["1"],
|
||||
Literal["2"],
|
||||
Literal["3"],
|
||||
Literal["4"],
|
||||
Literal["5"],
|
||||
Literal["6"],
|
||||
]
|
||||
] = None,
|
||||
job_type: Optional[
|
||||
List[
|
||||
Union[
|
||||
Literal["F"],
|
||||
Literal["C"],
|
||||
Literal["P"],
|
||||
Literal["T"],
|
||||
Literal["I"],
|
||||
Literal["V"],
|
||||
Literal["O"],
|
||||
]
|
||||
]
|
||||
] = None,
|
||||
job_type: Optional[
|
||||
List[
|
||||
Union[
|
||||
Literal["F"],
|
||||
Literal["C"],
|
||||
Literal["P"],
|
||||
Literal["T"],
|
||||
Literal["I"],
|
||||
Literal["V"],
|
||||
Literal["O"],
|
||||
]
|
||||
] = None,
|
||||
job_title: Optional[List[str]] = None,
|
||||
industries: Optional[List[str]] = None,
|
||||
location_name: Optional[str] = None,
|
||||
remote: Optional[List[Union[Literal["1"], Literal["2"], Literal["3"]]]] = None,
|
||||
listed_at: None | int = None,
|
||||
distance: Optional[int] = None,
|
||||
easy_apply: Optional[bool] = True,
|
||||
limit=-1,
|
||||
offset=0,
|
||||
**kwargs,
|
||||
]
|
||||
] = None,
|
||||
job_title: Optional[List[str]] = None,
|
||||
industries: Optional[List[str]] = None,
|
||||
location_name: Optional[str] = None,
|
||||
remote: Optional[List[Union[Literal["1"], Literal["2"], Literal["3"]]]] = None,
|
||||
listed_at: None | int = None,
|
||||
distance: Optional[int] = None,
|
||||
easy_apply: Optional[bool] = True,
|
||||
limit=-1,
|
||||
offset=0,
|
||||
**kwargs,
|
||||
) -> List[Dict]:
|
||||
"""Perform a LinkedIn search for jobs.
|
||||
|
||||
|
|
@ -167,8 +159,8 @@ class LinkedInEvolvedAPI(Linkedin):
|
|||
break
|
||||
results.extend(new_data)
|
||||
if (
|
||||
(-1 < limit <= len(results))
|
||||
or len(results) / count >= Linkedin._MAX_REPEATED_REQUESTS
|
||||
(-1 < limit <= len(results))
|
||||
or len(results) / count >= Linkedin._MAX_REPEATED_REQUESTS
|
||||
) or len(elements) == 0:
|
||||
break
|
||||
|
||||
|
|
@ -176,7 +168,7 @@ class LinkedInEvolvedAPI(Linkedin):
|
|||
|
||||
return results
|
||||
|
||||
def get_fields_for_easy_apply(self, job_id: str) -> List[Dict]:
|
||||
def get_fields_for_easy_apply(self,job_id: str) -> List[Dict]:
|
||||
"""Get fields needed for easy apply jobs.
|
||||
|
||||
:param job_id: Job ID
|
||||
|
|
@ -190,11 +182,13 @@ class LinkedInEvolvedAPI(Linkedin):
|
|||
|
||||
headers: Dict[str, str] = self._headers()
|
||||
|
||||
|
||||
headers["Accept"] = "application/vnd.linkedin.normalized+json+2.1"
|
||||
headers["csrf-token"] = cookies["JSESSIONID"].replace('"', "")
|
||||
headers["Cookie"] = cookie_str
|
||||
headers["Connection"] = "keep-alive"
|
||||
|
||||
|
||||
default_params = {
|
||||
"decorationId": "com.linkedin.voyager.dash.deco.jobs.OnsiteApplyApplication-67",
|
||||
"jobPostingUrn": f"urn:li:fsd_jobPosting:{job_id}",
|
||||
|
|
@ -259,7 +253,7 @@ class LinkedInEvolvedAPI(Linkedin):
|
|||
|
||||
return form_components
|
||||
|
||||
def apply_to_job(self, job_id: str, fields: dict, followCompany: bool = True) -> bool:
|
||||
def apply_to_job(self,job_id: str, fields: dict, followCompany: bool = True) -> bool:
|
||||
return False
|
||||
|
||||
# ToDo: Implement apply to job parser first
|
||||
|
|
@ -275,7 +269,7 @@ class LinkedInEvolvedAPI(Linkedin):
|
|||
# EXAMPLE OF WORKING PAYLOAD
|
||||
# 4005350454 is job_id, so need to be replaced with the job_id
|
||||
|
||||
# {
|
||||
#{
|
||||
# "followCompany": true,
|
||||
# "responses": [
|
||||
# {
|
||||
|
|
@ -355,10 +349,9 @@ class LinkedInEvolvedAPI(Linkedin):
|
|||
# }
|
||||
# ],
|
||||
# "trackingId": ""
|
||||
# }
|
||||
#}
|
||||
|
||||
# Push the commit to the repository and create a pull request to the v3 branch.
|
||||
<<<<<<< HEAD
|
||||
|
||||
def create_request_pdf(self, filename: str) -> str | None:
|
||||
"""
|
||||
|
|
@ -476,13 +469,10 @@ class LinkedInEvolvedAPI(Linkedin):
|
|||
with open(file_path, 'rb') as file:
|
||||
binary_data = file.read()
|
||||
return binary_data
|
||||
=======
|
||||
>>>>>>> upstream/v3
|
||||
|
||||
def set_job_as_applied(self, job_id: str) -> None:
|
||||
self.already_applied_jobs.append(job_id)
|
||||
|
||||
<<<<<<< HEAD
|
||||
def upload_linkedin_resume(self, cv_path: str) -> str | bool:
|
||||
url = self.create_request_pdf("resume.pdf")
|
||||
if url:
|
||||
|
|
@ -501,14 +491,6 @@ if __name__ == "__main__":
|
|||
|
||||
api: LinkedInEvolvedAPI = LinkedInEvolvedAPI(username="", password="")
|
||||
jobs = api.search_jobs(keywords="Frontend Developer", location_name="Italia", limit=100, easy_apply=True, offset=1, listed_at=None)
|
||||
=======
|
||||
|
||||
## EXAMPLE USAGE
|
||||
if __name__ == "__main__":
|
||||
api: LinkedInEvolvedAPI = LinkedInEvolvedAPI(username="", password="")
|
||||
jobs = api.search_jobs(keywords="Frontend Developer", location_name="Italia", limit=100, easy_apply=True, offset=1,
|
||||
listed_at=None)
|
||||
>>>>>>> upstream/v3
|
||||
for job in jobs:
|
||||
job_id: str = job["job_id"]
|
||||
|
||||
|
|
@ -532,3 +514,7 @@ if __name__ == "__main__":
|
|||
print(field)
|
||||
|
||||
break
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue