主页
Python
Python Requests head() 方法
demo_requests_head_allow_redirects2
运行 ❯
×
更改方向
保存代码
更改主题
import requests url = 'https://freew3c.com/python/demopage.php' x = requests.head(url, allow_redirects=True) #The server will redirect this url to 'https://freew3c.com/python/demopage.php' #and since the head method by default do not allow redirects, we must use allow_redirects=True. print(x.status_code)
C:\Users\My Name>python demo_requests_head_allow_redirects2.py
200