This commit is contained in:
2024-08-19 16:29:30 -07:00
parent ef7d0c3e05
commit 9fc5b35844
3 changed files with 203 additions and 52 deletions
+34 -15
View File
@@ -9,7 +9,8 @@ import { LoadingBar } from './misc.js';
const cookieJar = new CookieJar();
const axios = wrapper(axiosModule.create({
jar: cookieJar, // attach cookie jar
withCredentials: true
withCredentials: true,
// maxRedirects: Infinity
}));
@@ -123,9 +124,13 @@ class APIHelper {
getCookies(username, password) {
return new Promise(async (resolve, reject) => {
const spawn = (await import("child_process")).spawn;
const pythonProcess = spawn('python', ["auth.py", username, password]);
const pythonProcess = (await import("child_process")).exec(`python ${import.meta.dirname}/auth.py ${username} ${password}`);
pythonProcess.stdout.on('data', (data) => resolve(data.toString()));
pythonProcess.stderr.on('data', (data) => reject(data.toString()));
pythonProcess.on('error', reject);
pythonProcess.on('exit', (code) => console.log('done!', code));
});
}
@@ -146,7 +151,7 @@ class APIHelper {
JSESSIONID: scookie.get('JSESSIONID')
};
console.log(payload);
// console.log(payload);
// this.authheaders['cookies'] = res.headers['set-cookie'];
@@ -361,7 +366,7 @@ export default class linkedInAPIClass {
*/
async _makeReq(reqPath, isProfile = false, ignoreTimeoutErr = false) {
await this.evade();
const res = await axios.get(`https://www.linkedin.com/voyager/api/graphql?${reqPath}&queryId=${(!isProfile) ? "voyagerSearchDashClusters.f0c4f21d8a526c4a5dd0ae253c9b6e02" : "voyagerIdentityDashProfiles.5a6722404e6afd08958f5105e51cad51"}`, { headers: this.headers }).catch((err) => {
const res = await axios.get(`https://www.linkedin.com/voyager/api/graphql?${reqPath}&queryId=${(!isProfile) ? "voyagerSearchDashClusters.37920f17209f22c510dd410658abc540" : "voyagerIdentityDashProfiles.5a6722404e6afd08958f5105e51cad51"}`, { headers: this.headers }).catch((err) => {
if (err?.code === 'ECONNRESET' && ignoreTimeoutErr) return null;
console.error(err);
return null;
@@ -387,23 +392,37 @@ export default class linkedInAPIClass {
if (this.logAll) console.log("LOGGED IN!");
this.headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0',
'Host': 'www.linkedin.com',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; rv:128.0) Gecko/20100101 Firefox/128.0',
'Accept': 'application/vnd.linkedin.normalized+json+2.1',
'Accept-Language': 'en-US,en;q=0.5',
'Accept-Encoding': 'gzip, deflate, br',
'x-li-lang': 'en_US',
'x-li-track': '{"clientVersion":"1.13.14725","mpVersion":"1.13.14725","osName":"web","timezoneOffset":-7,"timezone":"America/Los_Angeles","deviceFormFactor":"DESKTOP","mpName":"voyager-web","displayDensity":1,"displayWidth":1920,"displayHeight":1080}',
'x-li-page-instance': 'urn:li:page:d_flagship3_search_srp_jobs;TvndZ7TATTy2i/ZUyyD3Zg==',
'csrf-token': 'ajax:2538600735149500238',
'x-restli-protocol-version': '2.0.0',
'x-li-pem-metadata': 'Voyager - Organization - LCP_Member=interest-pipeline',
'Accept-Encoding': 'gzip, deflate, br, zstd',
'DNT': '1',
'Sec-GPC': '1',
'Connection': 'keep-alive',
'Referer': 'https://www.linkedin.com/jobs/search/?currentJobId=3840672849&distance=25.0&geoId=103644278&keywords=temp&origin=HISTORY',
'Referer': 'https://www.linkedin.com/search/results/companies/?keywords=microsoft&origin=GLOBAL_SEARCH_HEADER&sid=5mA',
'Cookie': cookie,
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'TE': 'trailers'
'TE': 'trailers',
'x-li-lang': 'en_US',
'x-li-track': JSON.stringify({
clientVersion: '1.13.21804',
mpVersion: '1.13.21804',
osName: 'web',
timezoneOffset: 0,
timezone: 'Atlantic/Reykjavik',
deviceFormFactor: 'DESKTOP',
mpName: 'voyager-web',
displayDensity: 2,
displayWidth: 4096,
displayHeight: 2160
}),
'x-li-page-instance': 'urn:li:page:d_flagship3_search_srp_companies;bfbz9Kn/TamNtptZQMG4Mg==',
'csrf-token': 'ajax:1264483706853073695',
'x-restli-protocol-version': '2.0.0',
'x-li-pem-metadata': 'Voyager - Companies SRP=search-results'
};
}
+66
View File
@@ -0,0 +1,66 @@
import requests
import sys
# Why is this in a python file? Because the nodejs always returns HTTP 500
[_, username, password] = sys.argv
print(username, password)
AUTHHEADERS = {
"X-Li-User-Agent": "LIAuthLibrary:0.0.3 com.linkedin.android:4.1.881 Asus_ASUS_Z01QD:android_9",
"User-Agent": "ANDROID OS",
"X-User-Language": "en",
"X-User-Locale": "en_US",
"Accept-Language": "en-us",
}
res = requests.get(
f"https://www.linkedin.com/uas/authenticate",
headers=AUTHHEADERS,
)
scookies = res.cookies
payload = {
"session_key": username,
"session_password": password,
"JSESSIONID": scookies["JSESSIONID"],
}
# self.session.cookies = cookies
# self.session.headers["csrf-token"] = self.session.cookies["JSESSIONID"].strip(
# '"'
# )
# attempt to bypass the CAPTCHA
url = "https://www.linkedin.com/checkpoint/lg/login-challenge-submit?lastCv=AgFZ5ZeTx7tCrAAAAY7uQimE1X7IgBH77ZD3WENAX3Ag4x8TZtzjINmKy-o&_d=d&session_redirect=&vcd=AgGInyRZWZpvSgAAAY7uQky1qELAo1A9Q8uIrW_pobeD_O5eVFEGfVnkAhm7OjlNF--l_YYPbixT5yvxKnv23lrmx5LW8A&pageInstance=urn%3Ali%3Apage%3Ad_checkpoint_ch_captchaV2Challenge%3BfR3yNrJFTJ2Pk03CUmRNLw%3D%3D&controlId=d_checkpoint_ch_captchaV2Challenge-Submit&ut=35EW7sTFMrLrc1"
headers = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.5",
"Accept-Encoding": "gzip, deflate, br",
"Referer": "https://www.linkedin.com/checkpoint/challenge/AgGQ7wuRAH6jgwAAAY7uQimQEUhVjSHHvLpOiDFbjiliykkUTdy5O46FV6DCsi1TQ2V6TYPULzc9AG1ymUdFF7-zFbyAvw?ut=3yYrWkE6YrLrc1",
"DNT": "1",
"Sec-GPC": "1",
"Connection": "keep-alive",
"Cookie": "JSESSIONID=ajax:2538600735149500238; lang=v=2&lang=en-us; bcookie=\"v=2&ece64a43-fa8f-495d-8f16-942fbfda8432\"; bscookie=\"v=1&202404172251303c0c01ab-29c3-4cfb-8b72-dc6cca67d34dAQFoy9tgTQeA3gYImSFnGmrE-D7LUGdX\"; li_gp=MTsxNzEzMzk0MjkwOzA=; lidc=\"b=OGST04:s=O:r=O:a=O:p=O:g=3159:u=1:x=1:i=1713394290:t=1713480690:v=2:sig=AQGXW3NObtywt8GkIy518CDbVOTkgKAa\"; chp_token=AgGGFUgiWZoEVgAAAY7uQimBzBMFY8ddHZL5K3xcMFMp8q67sR_BKdcnnAS5t9I8QTUhrOZeVLVKm9lrvDziWlt3UQH7tALyInZIQA",
"Upgrade-Insecure-Requests": "1"
}
# Send the request
response = requests.get(url, headers=headers)
res = requests.post(
f"https://www.linkedin.com/uas/authenticate",
data=payload,
cookies=scookies,
headers=AUTHHEADERS,
)
print(res.json())
sys.stdout.flush()