Skip to content

Instantly share code, notes, and snippets.

@mouseos
Created October 10, 2022 14:10
Show Gist options
  • Save mouseos/cbf4f3ffbe67fc1170528e2164d5a4b8 to your computer and use it in GitHub Desktop.
Save mouseos/cbf4f3ffbe67fc1170528e2164d5a4b8 to your computer and use it in GitHub Desktop.
import requests
import json
#トークンを取得
def get_token():
headers = {
'authority': 'platform-api.tver.jp',
'accept': '*/*',
'accept-language': 'ja-JP,ja;q=0.9,en-US;q=0.8,en;q=0.7',
'content-type': 'application/x-www-form-urlencoded; charset=utf-8',
'origin': 'null',
'sec-ch-ua': '"Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'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/106.0.0.0 Safari/537.36',
}
data = {
'device_type': 'pc',
}
response = requests.post('https://platform-api.tver.jp/v2/api/platform_users/browser/create', headers=headers, data=data)
return(json.loads(response.text))#dictで返す
#番組json取得
def get_programs():
tokens=get_token();
platforn_uid=tokens["result"]['platform_uid'];
platform_token=tokens["result"]['platform_token'];
headers = {
'authority': 'platform-api.tver.jp',
'accept': '*/*',
'accept-language': 'ja-JP,ja;q=0.9,en-US;q=0.8,en;q=0.7',
'origin': 'null',
'sec-ch-ua': '"Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'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/106.0.0.0 Safari/537.36',
'x-tver-platform-type': 'web',
}
params = {
'platform_uid': platforn_uid,
'platform_token': platform_token,
'keyword': '',
'require_data': 'later',
}
response = requests.get('https://platform-api.tver.jp/service/api/v1/callSearch', params=params, headers=headers)
return(json.loads(response.text))
print(get_programs())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment