Created
February 3, 2021 14:48
-
-
Save Xavier59/8f44ac0b531b816ff86811fd2db0c7f7 to your computer and use it in GitHub Desktop.
Linkedin birhday updater
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
# Requirements : | |
# - python3 | |
# - requests (if not preinstalled, python3 -m pip install requests) | |
# | |
# Start by : | |
# - Filling login and password at line 66 | |
# - python3 app.py | |
from datetime import date | |
import requests | |
import re | |
class Linkedin: | |
def __init__(self, user, password): | |
self.user = user | |
self.password = password | |
def login(self): | |
self.s = requests.Session() | |
r = self.s.post( | |
"https://www.linkedin.com/checkpoint/lg/login-submit", | |
data=f"session_key={self.user}&loginCsrfParam=011a982e-60ce-46b1-8dfa-eb01f45f33ad&session_password={self.password}", | |
headers={ | |
"Cookie": 'bcookie="011a982e-60ce-46b1-8dfa-eb01f45f33ad"', | |
"Content-Type": "application/x-www-form-urlencoded", | |
}, | |
allow_redirects=False, | |
) | |
if r.status_code != 303: | |
print("Wrong login or password") | |
else: | |
self.jsession = r.cookies["JSESSIONID"].strip('"') | |
def change_birthday(self, day, month): | |
self.get_id() | |
r = self.s.post( | |
f"https://www.linkedin.com/voyager/api/identity/profiles/{self.id}/normProfileContactInfo?versionTag={self.version_tag}", | |
json={"patch": {"$set": {"birthDateOn": {"day": day, "month": month}}}}, | |
headers={ | |
"csrf-token": self.jsession, | |
}, | |
) | |
if r.status_code == 202: | |
print("Changed birthday !") | |
else: | |
print("Unexpected error while changing date, contact dev") | |
def get_id(self): | |
r = self.s.get( | |
"https://www.linkedin.com/in/edit/edit/contact-info/", | |
) | |
pattern = re.compile("/profiles/(.+)?/") | |
id_match = pattern.search(r.text) | |
pattern2 = re.compile("versionTag":"(\d+)"") | |
version_match = pattern2.search(r.text) | |
if id_match and version_match: | |
self.id = id_match.group(1) | |
self.version_tag = version_match.group(1) | |
else: | |
print("Error, couldn't find id token or version tag, aborting ...") | |
exit(0) | |
def main(): | |
linkedin = Linkedin("CHANGE_ME_LOGIN", "CHANGE_ME_PASSWORD") | |
linkedin.login() | |
linkedin.change_birthday( | |
int(date.today().strftime("%d")), int(date.today().strftime("%m")) | |
) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment