主页
Python
Python Requests get() 方法
demo_requests_get_cookies
运行 ❯
×
更改方向
保存代码
更改主题
import requests url = 'https://freew3c.com/python/demopage2.php' #use the 'cookies' parameter to send cookies to the server: x = requests.get(url, cookies = {"favcolor": "Red"}) print(x.text) #the 'demopage2.php' prints the value of the 'favcolor' cookie.
C:\Users\My Name>python demo_requests_get_cookies.py
<!DOCTYPE html>
<html>
<body>
<p>Favorite color: Red</p>
</body>
</html>