我正在尝试使用Python登录到LinkedIn,以从中获取一些数据。 但是在发送请求6个小时后,我得到的是相同的“您必须经过身份验证才能访问此页面。”响应。 我猜问题出在标题上。但是我无法使其工作。 这是我想出的:
dependency {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}
答案 0 :(得分:0)
这很普遍,但是有一个快速的解决方法
答案 1 :(得分:0)
def Login():
session = requests.Session() # Creating a session to contain the cookies
url = 'https://www.linkedin.com/login' # the url that contains the post paramters
Get_Headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en,en-US;q=0.9,ar;q=0.8",
}
main_html = session.get(url,headers=Get_Headers,verify=False).text
soup = BeautifulSoup(main_html, 'html.parser')
csrfToken = soup.find('input', {'name': 'csrfToken'}).get('value')
sIdString = soup.find('input', {'name': 'sIdString'}).get('value')
controlId = soup.find('input', {'name': 'controlId'}).get('value')
parentPageKey = soup.find('input', {'name': 'parentPageKey'}).get('value')
trk = soup.find('input', {'name': 'trk'}).get('value')
session_redirect= soup.find('input', {'name': 'session_redirect'}).get('value')
loginCsrfParam = soup.find('input', {'name': 'loginCsrfParam'}).get('value')
pageInstance = soup.find('input', {'name': 'pageInstance'}).get('value')
pageInstance = soup.find('input', {'name': 'pageInstance'}).get('value')
Post_Data = {
'csrfToken': csrfToken,
'session_key': 'email here',
'ac': 0,
'sIdString': sIdString,
'controlId': controlId,
'parentPageKey': parentPageKey,
'pageInstance': pageInstance,
'trk': trk,
'session_redirect': session_redirect,
'loginCsrfParam': loginCsrfParam,
# fp_data: {"X-kcnN2cez-f":"AwIHlXRpAQAAImHbUFfTzoZj1Eyqi8fC6QjI9Fmx9REX3bPOsas9PjU3F-c3AX8AAAGLr4YowLkAAAA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n9STAz0ZvMdDiA1Ju3Fu=7slJfvJeQqp6DhDymfU76wBED7IicNKNrcUn0Ub_T8hAzgw3QRMog_A=VoCHJNOkP2DOy_SELHVPtDPrFAeSsxAak=w5J8Ya5EqLE242Nr2sNPgrT8Je_zOkls6nMeiE_Zx=i5cM3f_3Y8nrJSgRIaLzue=QQ2-t=etBHbbaB8tnbtFmH1CFJdU_x9enMDEG-FqILtDtGOTdfLPbia1fgVGERGP_57gblo="}
'_d': 'd',
'session_password': 'password here'
}
print(Post_Data)
Get_Headers['referer'] = url
source = session.post(url='https://www.linkedin.com/checkpoint/lg/login-submit', data=Post_Data,headers=Get_Headers,verify=False, allow_redirects=True).text