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)

  • 相关阅读:
    Unity Ioc框架简单例子
    Newtonsoft.Json.Linq
    Quartz.net
    AngularJS
    Zookeeper
    mysql 游标CURSOR
    mysql 存储过程 CONCAT 字符串拼接
    MD5Util
    生成缩略图
    Asp.net MVC 基于Area的路由映射
  • 原文地址:https://www.cnblogs.com/jp-mao/p/6671059.html
Copyright © 2011-2022 走看看