Python学习笔记(27)~爬虫基础学习:查看response中的一些返回值

舟海君

关注

阅读 104

2023-01-12


查看response中的一些返回值

Demo

#!/usr/bin/python3
import urllib.request,urllib.error,urllib.parse

response=urllib.request.urlopen("http://www.baidu.com")
print("响应状态码:",response.status)#响应状态码
print("headers数据:",response.getheaders())
print("获取header中的Bdqid:",response.getheader("Bdqid"))#取出具体一个变量的值

运行结果

Python学习笔记(27)~爬虫基础学习:查看response中的一些返回值_python


精彩评论(0)

0 0 举报