DrissionPage/docs/使用方法/requests 功能使用.md
2021-12-10 19:02:42 +08:00

24 lines
723 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 连接参数
除了在创建时传入配置信息及连接参数如有必要s 模式下也可在每次访问网址时设置连接参数。
```python
headers = {'User-Agent': '......', }
cookies = {'name': 'value', }
proxies = {'http': '127.0.0.1:1080', 'https': '127.0.0.1:1080'}
page.get(url, headers=headers, cookies=cookies, proxies=proxies)
```
Tips
- 如果连接参数内没有指定s 模式会根据当前域名自动填写 Host 和 Referer 属性
- 在创建 MixPage 时传入的 Session 配置是全局有效的
# Response 对象
requests 获取到的 Response 对象存放在 page.response可直接使用。如
```python
print(page.response.status_code)
print(page.response.headers)
```