#-*- coding:UTF-8 -*- import requests def getHTMLText(url): try: r = requests.get(url, timeout = 30) r.raise_for_status() #如果状态不是200,引发HTTPError异常
爬取网页的通用代码框架
最新推荐文章于 2024-07-30 17:21:38 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)
#-*- coding:UTF-8 -*- import requests def getHTMLText(url): try: r = requests.get(url, timeout = 30) r.raise_for_status() #如果状态不是200,引发HTTPError异常