self_example/Spider/爬虫基本库/urllib库/urllibLearning.py

18 lines
394 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#-*- encoding:utf-8 -*-
'''
@Author : dingjiawen
@Date : 2023/10/17 21:40
@Usage : urllib库学习
@Desc :
'''
import urllib.request
# 基本使用返回一个response对象
# 无data即get请求有data即post请求data为bytes类型
response = urllib.request.urlopen("https://www.python.org")
print(response.status)
print(response.getheaders())
print(response.getheader('Server'))