apeye.requests_url¶
Extension of URL with support for interacting with the website using the Requests library.
New in version 0.2.0.
Classes:
|
Extension of |
|
Extension of |
Data:
Invariant |
- class RequestsURL(url='')[source]¶
Bases:
URLExtension of
URLwith support for interacting with the website using the Requests library.The
requests.Sessionused for this object – and all objects created using the/or.parentoperations – can be accessed using thesessionattribute. If desired, this can be replaced with a different session object, such as one using caching.Changed in version 0.3.0: The
urlparameter can now be a string or aURL.Changed in version 1.1.0: When a
RequestsURLobject is deleted or garbage collected, the underlyingrequests.Sessionobject it only closed if no objects hold references to the session. This prevents the session object of a global object from being inadvertently closed when one of its children is garbage collected.Methods:
__del__()Attempt to close session when garbage collected to avoid leaving connections open.
delete(**kwargs)Send a DELETE request using Requests.
get([params])Perform a GET request using Requests.
head(**kwargs)Send a HEAD request using Requests.
options(**kwargs)Send an OPTIONS request using Requests.
patch([data, json])Send a PATCH request using Requests.
post([data, json])Send a POST request using Requests.
put([data, json])Send a PUT request using Requests.
resolve([timeout])Resolves the URL into its canonical form.
Attributes:
The underlying requests session.
- __del__()[source]¶
Attempt to close session when garbage collected to avoid leaving connections open.
- delete(**kwargs)[source]¶
Send a DELETE request using Requests.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE
- Parameters
**kwargs – Optional arguments that
requests.request()takes.- Return type
- get(params=None, **kwargs)[source]¶
Perform a GET request using Requests.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET
- Parameters
params (
Union[Mapping[Union[str,bytes,int,float],Union[str,bytes,int,float,Iterable[Union[str,bytes,int,float]]]],str,bytes,Tuple[Union[str,bytes,int,float],Union[str,bytes,int,float,Iterable[Union[str,bytes,int,float]]]],None]) – Dictionary, list of tuples or bytes to send in the query string for therequests.Request. DefaultNone.**kwargs – Optional arguments that
requests.request()takes.
Changed in version 0.7.0: If
paramsisNonebut the URL has a query string, the query string will be parsed and used forparams.- Return type
- head(**kwargs)[source]¶
Send a HEAD request using Requests.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD
- Parameters
**kwargs – Optional arguments that
requests.request()takes. If allow_redirects is not provided, it will be set to False (as opposed to the defaultrequests.request()behavior).- Return type
- options(**kwargs)[source]¶
Send an OPTIONS request using Requests.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS
- Parameters
**kwargs – Optional arguments that
requests.request()takes.- Return type
- patch(data=None, json=None, **kwargs)[source]¶
Send a PATCH request using Requests.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH
- Parameters
data (
Union[None,str,bytes,MutableMapping[str,Any],List[Tuple[str,Optional[str]]],Tuple[Tuple[str,Optional[str]]],IO]) – Dictionary, list of tuples, bytes, or file-like object to send in the body of therequests.Request. DefaultNone.json – json data to send in the body of the
requests.Request. DefaultNone.**kwargs – Optional arguments that
requests.request()takes.
- Return type
- post(data=None, json=None, **kwargs)[source]¶
Send a POST request using Requests.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
- Parameters
data (
Union[None,str,bytes,MutableMapping[str,Any],List[Tuple[str,Optional[str]]],Tuple[Tuple[str,Optional[str]]],IO]) – Dictionary, list of tuples, bytes, or file-like object to send in the body of therequests.Request. DefaultNone.json – json data to send in the body of the
requests.Request. DefaultNone.**kwargs – Optional arguments that
requests.request()takes.
- Return type
- put(data=None, json=None, **kwargs)[source]¶
Send a PUT request using Requests.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT
- Parameters
data (
Union[None,str,bytes,MutableMapping[str,Any],List[Tuple[str,Optional[str]]],Tuple[Tuple[str,Optional[str]]],IO]) – Dictionary, list of tuples, bytes, or file-like object to send in the body of therequests.Request. DefaultNone.json – json data to send in the body of the
requests.Request. DefaultNone.**kwargs – Optional arguments that
requests.request()takes.
- Return type
- class TrailingRequestsURL(url='')[source]¶
Bases:
RequestsURLExtension of
RequestsURLwhich adds a trailing slash to the end of the URL.New in version 0.5.0.
- __str__()[source]¶
Returns the
TrailingRequestsURLas a string.- Return type
- _R = TypeVar(_R, bound=RequestsURL)¶
Type:
TypeVarInvariant
TypeVarbound toapeye.requests_url.RequestsURL.