import requests


def query_params_o_token(net_url, my_session, origin_url):
    net_url = "https://t.livepocket.jp/purchase/confirm?id=314095&reserved_session_id=809279"
    result = requests.Session()
    header = {
        'Host': 't.livepocket.jp',
        'User-Agent': "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) "
                      "Chrome/69.0.3947.100 Safari/537.36",
        # 'Referer': f'{origin_url}',
    }
    cookies = {
        'ci_session': f'{my_session}'
    }
    response = result.get(net_url, headers=header, cookies=cookies, allow_redirects=False)
    print('response', response)
    location_url = response.headers['Location']
    region_string = location_url.split('?')[1]
    params = region_string.split('&')
    data = {
        'id': params[0].split('=')[1],
        'reserved_session_id': params[1].split('=')[1],
        'otoken': params[2].split('=')[1]
    }

    return data


if __name__ == '__main__':
    my_session = {
        'ci_session': 'w2uNUg2evDN3Y5p9FF6ov%2BeGbOd1bG2G6TcquqbP6s%2BS8sHGzdxFsQiX9MZfADOXtJoTezlRRTMnSHN6eKM4Jj2R9JfAqm4H5VDBp6uMnftQGB4tJLSqk6xAKRi3R9BeAwFh8KQF75VAY88apyvHXzSIr3Cbad5dS2kY4bvj3AiKORmlwm8XamH%2FRr5%2BGYVc20ci0TZ5%2FRft5%2FiU6Du3mBKVqh4wQmKezkwZd7VIWC5FaApglFF%2FNAeuBxgsCnrBEJABu734BJXqHECPiEWWhI5BYx1X2V%2BjIxUI%2Fv6%2FwLDsPPmdwq0tO3mAMHSyMfo402xjZN0iVX3ZwFby2%2Bp8VUSfJdz7DfgZO1FcC62H2n12yJUaatCcXeWn6RgykRzO04o%2BeasJVIwML215vCI6YmgvdRiwSCDlr7QB4%2F5Ae7ZByAE0qk9Ofx4yEHXfjNSlN5j1JN7iNN6NYMkc0raVsQ%3D%3D'
    }

    query_params_o_token(None, my_session, None)
