我從 LinkedIn 抓取資料時遇到問題。
我認為檔案太復雜了......
這里的問題是,我想發出請求(GET)并獲取例如我的提要/帖子/聊天或其他任何資料。
這是我的代碼:
import json
import requests
# URL = "https://www.linkedin.com/voyager/api/voyagerMessagingDashConversationNudges"
URL = "https://www.linkedin.com/voyager/api/identity/dash/profiles"
cookies = {
#Cookies are here
}
params = {
'decorationId': 'com.linkedin.voyager.dash.deco.identity.profile.WebTopCardCore-6',
'memberIdentity': 'maria-albert-137632240',
'q': 'memberIdentity',
}
def get_group(url: str, cookies: dict, data:dict, header: dict):
response = requests.get(url=url, cookies=cookies, data=json.dumps(data), headers=header)
response.raise_for_status()
return response.json()
if __name__ == "__main__":
print("sending request to Server:\n")
get_group(url=URL, cookies=cookies, data=params, header=headers)
但我做不到,錯誤-->raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: INKApi Error for url: https://www.linkedin.com/voyager/api/identity/dash/profiles
謝謝你的幫助。
uj5u.com熱心網友回復:
您只需要像這樣設定標題:
header = {
"accept": 'application/vnd.linkedin.normalized json 2.1',
"cookie": 'JSESSIONID="ajax:abcd"; li_at=abcdabcd',
}
因此將有效負載填充為所需的端點。
您無需創建應用程式即可訪問令牌或其他任何內容。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/498119.html
上一篇:C中的字串意外截斷
