最基础的urllib.request.urlopen()基本使用
发布日期:2021-05-10 05:24:42 浏览次数:10 分类:精选文章

本文共 1207 字,大约阅读时间需要 4 分钟。

������Python������Python������

import urllib.requesturl = 'https://www.python.org' ������������������������������������������������ req = urllib.request.Request(url) ��������������������������� response = urllib.request.urlopen(url) ������������������ print(type(response))

���������������������������������HTTPResponse������������������������������������������������������������������������������������

���������������������

  • read():������������������
  • fileno():���������������������
  • getheader(name):������������������������
  • getheaders():������������������������
  • status:������HTTP���������
  • reason:���������������������
  • debuglevel:������������������
  • closed:���������������������������

������������������

html = response.read().decode('utf-8')

print(html)

"> ���������������
urllib.request.urlopen()������������������������������������������������HTTPResponse������������������������
status������������������HTTP���������������200���������������404������������������������������������������������������������������������
上一篇:举例urlopen中的data用法
下一篇:从placekitten网页上上抓图片

发表评论

最新留言

不错!
[***.144.177.141]2025年04月29日 00时47分27秒