Skip to content

Latest commit

 

History

History
84 lines (50 loc) · 2.33 KB

AmzProduct.md

File metadata and controls

84 lines (50 loc) · 2.33 KB

Class Definition

AmzProduct(html_element=None):

The AmzProduct class extends the AmzBase class and, as such the following attributes are available to be called as an index call or as an attribute:

  • title (str): The name of the product.
  • product_url (str) A url directly to the product's Amazon page.
  • image_url (str) A url to the product's default image.
  • rating (AmzRating) An AmzRating object.
  • prices (dict) A dictionary of prices, with the price type as a key and a string for the price value (see get_prices to get float values).
  • extra_attributes (dict) Any extra information that can be extracted from the product.
  • subtext (list) A list of strings under the title, typically the author's name and/or the date of publication.

This class should usually not be instantiated directly (rather be used in an AmzSear object) but can be created by passing an HTML element to the constructor. If nothing is passed, an empty AmzProduct object is created.

Optional Args:

html_element (LXML root): A root for an HTML tree derived from an element on an Amazon search page.

Class Methods

get(key, default=None, raise_error=False):

Inherited method from AmzBase.

get_prices(key=None):

Gets a list of floats from the dictionary of price text. A key can be passed to explicitly specify the prices to select. If the key is None, all prices keys are used.

Optional Args:

key (str or list): A key or list of keys to in the price dictionary.

Returns:

list: List of floats for the subset of price specified.

is_valid():

Inherited method from AmzBase.

items():

Inherited method from AmzBase.

keys():

Inherited method from AmzBase.

to_dict(recursive=True, flatten=False):

Inherited method from AmzBase.

to_series(recursive=True, flatten=False):

Inherited method from AmzBase.

values():

Inherited method from AmzBase.