为什么我通过浏览器正常关注用户调用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)