首页 > 编程 > Python > 正文

Python中获取网页状态码的两个方法

2019-11-25 18:07:16
字体:
来源:转载
供稿:网友

第一种是用urllib模块,下面是例示代码:

复制代码 代码如下:

import urllib
status=urllib.urlopen("//www.VeVB.COm").code
print status

第二章是用requests模块,下面是例示代码:

复制代码 代码如下:

import requests
code=requests.get("//www.VeVB.COm").status_code
print code

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表