Two methods in Python to get the status code for a web page
- 2020-04-02 14:20:15
- OfStack
The first is to use the urllib module, the following is the example code:
import urllib
status=urllib.urlopen("//www.jb51.net").code
print status
Chapter 2 USES the requests module. Here is the sample code:
import requests
code=requests.get("//www.jb51.net").status_code
print code