Home > Backend Development > Python Tutorial > Python中获取网页状态码的两个方法

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

WBOY
Release: 2016-06-10 15:19:13
Original
1076 people have browsed it

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

复制代码 代码如下:

import urllib
status=urllib.urlopen("http://www.jb51.net").code
print status

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

复制代码 代码如下:

import requests
code=requests.get("http://www.jb51.net").status_code
print code
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template