在 Python 中,你可以使用 `requests` 库来发送 HTTP 请求并打开网页。以下是使用 `requests` 库打开网页的基本步骤:
1. 安装 `requests` 库:
```
pip install requests
2. 导入 `requests` 库:
```python
import requests
3. 使用 `requests.get()` 方法发送 GET 请求并获取响应:
```python
response = requests.get(url)
其中 `url` 是你想要打开的网页地址。
4. 处理响应内容,例如获取网页的 HTML 内容:
```python
html_content = response.text
5. (可选)使用 `BeautifulSoup` 库解析 HTML 内容:
```python
from bs4 import BeautifulSoup
soup = BeautifulSoup(html_content, 'html.parser')
6. 提取网页中的数据,如标题、正文、链接等。
以上步骤可以帮助你使用 Python 爬虫打开网页并提取所需信息。