Advanced API Reference¶
The following section outlines the API of gd.py for advanced usage.
HTTP Client¶
-
class
gd.HTTPClient(*, url: Union[str, yarl.URL] = 'http://www.boomlings.com/database', proxy: Optional[str] = None, proxy_auth: Optional[aiohttp.helpers.BasicAuth] = None, timeout: Union[float, int] = 150, game_version: gd.converters.GameVersion = <GameVersion major=2 minor=1>, binary_version: gd.converters.Version = <Version major=3 minor=5>, gd_world: bool = False, forwarded_for: Optional[str] = None, use_user_agent: bool = False)[source]¶ -
async
download(url: Union[yarl.URL, str], method: str = 'GET', chunk_size: int = 65536, with_bar: bool = False, close: bool = False, file: Optional[Union[str, pathlib.Path, IO]] = None, **kwargs) → Optional[bytes][source]¶ Download the file at
urlwithmethod.- Parameters
method (
str) – HTTP method to send request with. Default isGET.url (Union[
URL,str]) – URL to request file from.chunk_size (
int) – Amount of data to read for one chunk.-1to read until EOF.with_bar (
bool) – Whether to show progress bar when downloading.Falseby default.close (
bool) – Whether to close the underlyingfileafter finishing.file (Optional[Union[
str,Path, IO]]) – File to write downloaded data to. If not given, this function returns all the data as the result.**kwargs – Keywoard arguments to pass to
aiohttp.ClientSession.request().
- Returns
Data downloaded, if
fileis not given orNone. Otherwise, returnsNone.- Return type
Optional[
bytes]
-
async