python爬取https://www.yuque.com/chengxuyuanyideng/wmiqe2下整个网页内容
时间: 2023-09-07 15:13:15 浏览: 273
项目演示地址:https://www.bilibili.com/video/BV11g4y1K77e/
以下是使用Python爬取https://www.yuque.com/chengxuyuanyideng/wmiqe2整个网页内容的示例代码:
```python
import requests
url = "https://www.yuque.com/chengxuyuanyideng/wmiqe2"
response = requests.get(url)
if response.status_code == 200:
html_content = response.content.decode("utf-8")
print(html_content)
else:
print(f"Failed to get content from {url}, status code: {response.status_code}")
```
这段代码使用Python的requests模块向目标URL发送GET请求,并获取响应内容。如果响应状态码为200,则说明请求成功,将响应内容使用UTF-8编码转换后打印出来。否则打印出请求失败的信息。
阅读全文