Extreme API with Python
Part no.9036931-00 Rev AA February 2021
'ftpwrapper', 'getproxies', 'getproxies_environment', 'getproxies_registry',
'hashlib', 'http', 'install_opener', 'io', 'localhost', 'noheaders', 'os',
'parse_http_list', 'parse_keqv_list', 'pathname2url', 'posixpath',
'proxy_bypass', 'proxy_bypass_environment', 'proxy_bypass_registry', 'quote',
're', 'request_host', 'socket', 'splitattr', 'splithost', 'splitpasswd',
'splitport', 'splitquery', 'splittag', 'splittype', 'splituser',
'splitvalue', 'ssl', 'string', 'sys', 'tempfile', 'thishost',
'time', 'to_bytes', 'unquote', 'unquote_to_bytes', 'unwrap', 'url2pathname',
'urlcleanup', 'urljoin', 'urlopen', 'urlparse', 'urlretrieve', 'urlsplit',
'urlunparse', 'warnings']
The following example shows how to use urlopen, and how to find other functions:
from urllib import request
resp = request.urlopen('HTTPS://www.youtube.com')
print(dir(resp))
Perform a dir() of the object returned from request.urlopen to see more functions.
['__abstractmethods__', '__class__', '__del__', '__delattr__', '__dict__',
'__dir__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__',
'__ge__', '__getattribute__', '__gt__', '__hash__', '__init__',
'__init_subclass__', '__iter__', '__le__', '__lt__', '__module__', '__ne__',
'__new__', '__next__', '__reduce__', '__reduce_ex__', '__repr__',
'__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_abc_impl',
'_checkClosed', '_checkReadable', '_checkSeekable', '_checkWritable',
'_check_close', '_close_conn', '_get_chunk_left', '_method', '_peek_chunked',
'_read1_chunked', '_read_and_discard_trailer', '_read_next_chunk_size',
'_read_status', '_readall_chunked', '_readinto_chunked', '_safe_read',
'_safe_readinto', 'begin', 'chunk_left', 'chunked', 'close', 'closed',
'code', 'debuglevel', 'detach', 'fileno', 'flush', 'fp', 'getcode',
'getheader', 'getheaders', 'geturl', 'headers', 'info', 'isatty', 'isclosed',
'length', 'msg', 'peek', 'read', 'read1', 'readable', 'readinto',
'readinto1', 'readline', 'readlines', 'reason', 'seek', 'seekable', 'status',
'tell', 'truncate', 'url', 'version', 'will_close', 'writable', 'write',
'writelines']
The following example shows how to use these functions:
from urllib import request
resp = request.urlopen('HTTPS://www.python.org')
print(resp.code)
print(resp.length)
data = resp.read()