# 将给定的HTTP请求头信息转为字典格式的headers http_headers = """ Accept: application/json, text/plain, */* Accept-Encoding: gzip, deflate, br, zstd Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6 Connection: keep-alive Content-Length: 22 Content-Type: application/json;charset=UTF-8 Cookie: SECKEY_ABVK=4xWRKdQvkKXaHdjRs0UoD0K4ye/ZDQGqa2YKVYXgJPk%3D; BMAP_SECKEY=2Sq_06ybvD0Wg-a66PwUio1MexnVk5iBqvZXLfylc3j_niIBT39XTp3vYGWHni2NENVtAgJ7EH_NmpRApABDKdJ1a8ueb_LOkI4DREjJQxZScW04rt6ewG9S6X8ySagoNhWgECBq6U8xqRKMfPf-e5PopnflJf-Kuoc97MeNbK8wXTA31ebgzl5ISEIQ9ubj Host: www.casmooc.cn Origin: https://www.casmooc.cn Sec-Fetch-Dest: empty Sec-Fetch-Mode: cors Sec-Fetch-Site: same-origin User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0 sec-ch-ua: "Microsoft Edge";v="125", "Chromium";v="125", "Not.A/Brand";v="24" sec-ch-ua-mobile: ?0 sec-ch-ua-platform: "Windows" x-access-browser-info: chrome 125.0.0.0 x-access-device-mac: x-access-device-name: x-access-device-system: Win10 x-access-device-type: WEB x-access-location-info: x-access-origin: aHR0cHM6Ly93d3cuY2FzbW9vYy5jbg== x-access-token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3MTg5MzU1MjIsIm9wZXJhdG9ySWQiOiIxMTA0OTI5OTg0In0.pKm0OjJJt8m8g-ft5ONIdRGW0O3yETAeaJ9HT6dTinA """ def parse_headers(header_str): headers = {} for line in header_str.strip().split("\n"): key, value = line.split(":", 1) headers[key.strip()] = value.strip() return headers headers_dict = parse_headers(http_headers) print(headers_dict)