@UltraRazrab228

Python requests к выдает ошибку TypeError: string indices must be integers. Почему?

Выдает
Traceback (most recent call last):
  File "D:\python projects\MyVisit\dbtest.py", line 28, in <module>
    DatesList = requests.get(
  File "D:\python projects\MyVisit\venv\lib\site-packages\requests\api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "D:\python projects\MyVisit\venv\lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "D:\python projects\MyVisit\venv\lib\site-packages\requests\sessions.py", line 573, in request
    prep = self.prepare_request(req)
  File "D:\python projects\MyVisit\venv\lib\site-packages\requests\sessions.py", line 471, in prepare_request
    cookies = cookiejar_from_dict(cookies)
  File "D:\python projects\MyVisit\venv\lib\site-packages\requests\cookies.py", line 537, in cookiejar_from_dict
    cookiejar.set_cookie(create_cookie(name, cookie_dict[name]))
TypeError: string indices must be integers

Интернет перерыл, не нашёл ничего толкового.

import requests
import datetime

ServiceId = 4706

cookies = {
    "rbzid": "lG6W14/mLTuc2wAoWxOY0sStIW1f+t68Dx3xsMTQ7lWF939BnVJaavF53o78wjekF3J0pLTCwjP+wEycIEGDkoZF+TYrUjQHT8oAq7iJb"
             "GgUcdGVfHHJJrQVaqC0FrHrr+IqUE2wdvj1UpJ1gggfbKvF+fch6g76VjZ0YWEYYyohVkhw+uou7dZS2LQwVdCiixGwiPUcel9Cfcu8Gr"
             "61LBK58zhdNx+EVYLn118cPEJodYHtcs6BjBchaRJrlTxfHE2mM2E3UtN5QlhDOIk+tw==",
    "ARRAffinity": "b1ef89074c71e161dc4fc9e1fb894062be585b15fd3db58dcfd3dfb656c73999",
    "ARRAffinitySameSite": "b1ef89074c71e161dc4fc9e1fb894062be585b15fd3db58dcfd3dfb656c73999", "GCLB": "CKqHz6TWhIGBAQ",
    "mvcnm": "Israel",
    "mvcid": 1,
    "mvcc": "il",
    "mvlng": "en",
    "_ga": "GA1.2.103207640.1672226790",
    "_gid": "GA1.2.5619508.1672226790",
    "CentralJWTCookie": "jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Im92VFc2ckQ4ZmExM1V1cUdKT1BQNkFqa2NMQSJ9.eyJpc"
                        "3MiOiJodHRwOi8vY2VudHJhbC5xbm9teS5jb20iLCJhdWQiOiJodHRwOi8vY2VudHJhbC5xbm9teS5jb20iLCJuYmYiOjE"
                        "2NzIyMjY4MDMsImV4cCI6MTY3MjIzMDQwMywidW5pcXVlX25hbWUiOiIzZmQ3NDg5OS1iN2ExLTRkYmMtYjUzYi1kMjVlN"
                        "TZmODExMzYiLCJ1aWQiOiI0ZVhqU1pPZUFweDlIZ0hSaCt0S1FnPT0ifQ.UE49_ndNaPmQV0wIpa8Oux-TbSUTyrybyXdE"
                        "ma-BRTqRG58De6jZgpXosCVrueLq3VdxQgOdkmnV-6i3OSpCA1l5NL3Jes-_JuMqH2LBwx9zibd4Dr6CsDxxY2j-LjlVLX"
                        "XJJ20nSA_kxWDSpfo_k93VPXtfCRNKR2XaaosuW1IbjzGaiiK0h_FunoI8qVqML4VdYYzIQIxSOgyeIRc2h4B3qtbEf8Or"
                        "-TtoEBXdCRii7DgBJpTDY_h2h1sH5bCpGv-n4I-v8thbQLOsymBHjj0ONMTJ4WeUBzTRNr3oZ9WhEDC7SADcIW2B7Rt5Pj"
                        "dr7zA1uVkPZgnjaX694msfiA",
    "_gat": 1}

DatesList = requests.get(
    "https://central.myvisit.com/CentralAPI/SearchAvailableDates?maxResults=31&serviceId={}&startDate={}".format(
        ServiceId, datetime.datetime.now().date()),
    headers={
        "accept": "application/json, text/plain, */*",
        "accept-language": "en",
        "application-api-key": "8640a12d-52a7-4c2a-afe1-4411e00e3ac4",
        "application-name": "myVisit.com v3.5",
        "sec-ch-ua": "\"Opera GX\";v=\"93\", \"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"107\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"Windows\"",
        "sec-fetch-dest": "empty",
        "sec-fetch-mode": "cors",
        "sec-fetch-site": "same-site"
    }, cookies=cookies).text
print(DatesList)
  • Вопрос задан
  • 186 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы