投資信託のポートフォリオを取得したい。モーニングスターで見れます( https://www.morningstar.co.uk/uk/funds/snapshot/snapshot.aspx?id=F00000ZG4Z&tab=3 )
開発ツールで API を見つけましたが、応答 401 しか取得できません - 承認されていません。
ここにコード:
import requests
url = 'https://www.us-api.morningstar.com/sal/sal-service/fund/portfolio/holding/v2/F00000ZG4Z/data'
params = {
'premiumNum': '10',
'freeNum': '10',
'languageId': 'en-GB',
'locale': 'en-GB',
'clientId': 'MDC_intl',
'benchmarkId': 'category',
'component': 'sal-components-mip-holdings',
'version': '3.40.1'
}
headers = {
'accept': '*/*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7',
'authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI3RUI4NDcyRi1FRjk4LTQ0ODgtQjJGQS0zQzMyQUQyQjdCNUYiLCJjdXN0b206ZGF0YV9yb2xlIjpbIlFTLk1hcmtldHMiLCJRUy5QdWxscXMiLCJTQUwuU2VydmljZSJdLCJjdXN0b206dWltX3JvbGVzIjoiIiwiY3VzdG9tOmNvbmZpZ19pZCI6IkVVUlRMX0VDIiwiaXNzIjoiVUlNIiwiZXhwIjoxNjEyNzkzNzgwLCJjdXN0b206cm9sZSI6WyJFQy5TZXJ2aWNlLkNvbmZpZ3VyYXRpb24iLCJFQy5TZXJ2aWNlLkhvc3RpbmciXSwiaWF0IjoxNjEyNzkwMTgwLCJjdXN0b206Y29tcGFueV9pZCI6IjUzNGJiMTM0LTMwNWYtNDhhYi04MmYxLWNjZTBlZDFlYTgzYSIsImN1c3RvbTppbnRlcm5hbF9jb21wYW55X2lkIjoiQ2xpZW50MCJ9.rVnAGGBsBxv3XMnBkAUJdo9tJmrsBGqjj2Wxtz0CLdz7MzErej8RBbVfDOEd1xdxmSd5YpAxFA_kuu41r8jyhCTAAvtBE6gWzizXMKxbZ7RQ9hxnWm3dVnsHspWKCwCCQl5B2WpBjDbTH-edBHmTLuUrq9Qc3_2r8Lx28-oFbxXtzdmlSssgtZqdz2dMXN-Fo8LYMrTPtqt0Kv_lwQMmH42_PwZd6BqtzMvpqN1rzCHRFN-y5xL4yZ_PGBviuhD841mXVNCWnv8WGYHOK5p0JEJ7pg17O2fvEhuMxrpwvmC4LRELsA-QRgCo15UpOp_AHcxg_r7HPxPA9TtHZUy6Rw',
'credentials': 'omit',
'origin': 'https://www.morningstar.co.uk',
'referer': 'https://www.morningstar.co.uk/',
'sec-ch-ua': '"Chromium";v="88", "Google Chrome";v="88", ";Not A Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'cross-site',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36',
'x-api-requestid': '6c20fb56-8055-aa34-1632-5f5a8dbaddde',
'x-sal-contenttype': 'e7FDDltrTy+tA2HnLovvGL0LFMwT+KkEptGju5wXVTU='
}
response = requests.get(url, params=params, headers=headers)
print(response)
どうすれば応答を得ることができるか分かりますか?
ありがとうございました