zoukankan      html  css  js  c++  java
  • urllib模块

    urllib.request

    1、定义

      用于打开URL的可扩展库,定义了基本和摘要式身份验证、重定向、cookies等应用中打开URL(主要是HTTP)的函数和类。

    2、函数

      urllib.request.urlopen(url,data=None,url, data=None)

      url:网址

      data:若HTTP请求是GET则data为None,若为POSTdata必须有数据

      返回一个对象

    from urllib.request import urlopen
    
    html = urlopen("http://pythonscraping.com/pages/page1.html")
    print(html.read())

    urllib.error

    1、定义

      由urllib.request引发的异常类,基本异常类是URLError

    2、函数

      exception urllib.error.URLError

      exception urllib.error.HTTPError

      exception urllib.error.ContenTooShortError(msg, content)

  • 相关阅读:
    盘子序列
    最大矩形面积
    【模板】ST表
    排队
    map循环遍历
    vue循环遍历给div添加id
    正则 匹配
    字符串拼接
    js对象追加到数组里
    二级标题左侧加粗线条
  • 原文地址:https://www.cnblogs.com/jp-mao/p/6671059.html
Copyright © 2011-2022 走看看