问个问题
查看原帖
问个问题
916276
b9113fced86a32cad0d8楼主2024/12/16 23:27

为什么我通过浏览器正常关注用户调用API时的状态码是200

但是直接访问该URL时,状态码是418

然后我在利用Python爬虫发送POST请求时是404

import requests

url = 'https://www.luogu.com.cn/api/user/updateRelationShip'

data = {
    'key1': 'value1',
    'key2': 'value2'
}
#数据还没准备好,应该不是这个的原因吧

response = requests.post(url, data=data)

if response.status_code == 200:
    print('POST请求成功!')
    print(response.text)
else:
    print('POST请求失败,状态码:', response.status_code)

2024/12/16 23:27
加载中...