The 'compress' parameter is not a valid parameter for the requests.get() method. It should be removed from the function call. The requests library handles compression automatically if the server supports it.

Here's the corrected code:

import requests

headers = {
    "authority": "free1-api.cveoy.top",
    "accept": "*/*",
    "accept-language": "en-US,en;q=0.9,vi;q=0.8",
    "content-type": "application/json",
    "origin": "https://www.cveoy.com",
    "referer": "https://www.cveoy.com/",
    "sec-ch-ua": '"Microsoft Edge";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
    "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/111.0.0.0 Safari/537.36 Edg/111.0.1661.62"
}

data = {
    "prompt": "why altman changed openai from non-profit to cap profit?\n\n"
}

urls = [
    "https://www.cveoy.com/live2dw/assets/mtn/idle.mtn",
    "https://www.cveoy.com/live2dw/assets/mtn/idle.mtn",
    "https://www.cveoy.com/live2dw/assets/mtn/idle.mtn",
    "https://www.cveoy.com/live2dw/assets/mtn/idle.mtn",
    "https://www.cveoy.com/live2dw/assets/mtn/idle.mtn",
    "https://www.cveoy.com/live2dw/assets/mtn/idle.mtn",
    "https://free1-api.cveoy.top/v3/completions"
]

for url in urls:
    response = requests.get(url, headers=headers, data=data, stream=True)
    response.raw.decode_content = True

The stream=True parameter is used to handle large responses by streaming the data instead of loading the entire response into memory. This helps prevent memory issues when dealing with large files or API responses.

Explanation of the Error:

The compress parameter is not part of the requests.get() method's arguments. This parameter is typically used in other libraries or contexts where you need to explicitly control compression. The requests library handles compression automatically if the server supports it.

Key Takeaways:

  • requests.get() does not require a compress parameter, and using it will result in an error.
  • Use stream=True to handle large responses efficiently.
  • The requests library automatically handles compression if supported by the server.
Python Requests Error: 'compress' Parameter Not Supported in requests.get()

原文地址: https://www.cveoy.top/t/topic/njS7 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录