urllib.request.urlopen()用法

  • 请求模块定义了以下功能:
    urllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None, capath=None, cadefault=False, context=None) 
    Open the URL url, which can be either a string or a Request object.
    打开URL URL,它可以是字符串或请求对象。
    data must be an object specifying additional data to be sent to the server, or None if no such data is needed. See Request for details.
    数据必须是指定要发送到服务器的附加数据的对象,否则不需要这些数据。
    有关详细信息,请参阅请求。
    urllib.request module uses HTTP/1.1 and includes Connection:close header in its HTTP requests.
    urllib。请求模块使用HTTP/1.1并包括连接:在其HTTP请求中关闭头部。
    The optional timeout parameter specifies a timeout in seconds for blocking operations like the connection attempt (if not specified, the global default timeout setting will be used). This actually only works for HTTP, HTTPS and FTP connections.
    可选的timeout参数指定了阻塞操作(如未指定的全局默认超时设置)的秒数。这实际上只适用于HTTP、HTTPS和FTP连接。
    If context is specified, it must be a ssl.SSLContext instance describing the various SSL options. See HTTPSConnection for more details.
    如果指定了上下文,它必须是一个ssl。描述各种SSL选项的SSLContext实例。有关更多细节,请参见HTTPSConnection。
    The optional cafile and capath parameters specify a set of trusted CA certificates for HTTPS requests. cafile should point to a single file containing a bundle of CA certificates, whereas capath should point to a directory of hashed certificate files. More information can be found in ssl.SSLContext.load_verify_locations().
    可选的cafile和capath参数为HTTPS请求指定了一组受信任的CA证书。
    cafile应该指向包含一个CA证书包的单个文件,而capath应该指向一个哈希证书文件的目录。
    在ssl.sslcontext.load_verify_location()中可以找到更多的信息。
    The cadefault parameter is ignored.
    cadefault参数被忽略。
  • This function always returns an object which can work as a context manager and has methods such as
  • 该函数始终返回一个对象,该对象可以作为上下文管理器工作,并具有诸如此类的方法。
geturl() � return the URL of the resource retrieved, commonly used to determine if a redirect was followed 
geturl()�返回的URL资源检索,常用来确定一个重定向之后
info() � return the meta-information of the page, such as headers, in the form of an email.message_from_string() instance (see Quick Reference to HTTP Headers) 
info()�返回页面的元信息,如标题,的形式email.message_from_string()实例(参见快速参考HTTP头)
getcode() � return the HTTP status code of the response. 
getcode()�返回响应的HTTP状态代码。参考HTTP头)

  • 
    
  •  



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值