WBparser

class wbparser.main.WBparser(ids: Union[None, List[int], List[str]] = None, urls: Union[None, List[str]] = None, result: Union[None, List[dict]] = None)

Bases: object

A class used to parse data from Wildberries. Pass several identifiers/urls to one WBparser object to make sure that Scrapy will work asynchronously.

Examples

parser = WBparser()
parser.parse_data(ids=[<product_id_1>])
parser.save_data()
parser = WBparser()
parser.parse_data(urls=[<url_1>, <url_2>, <url_3>,], ids=[<product_id_1>, <product_id_2>,])
parser.save_data(file_format='json', file_name='rareProducts')
print(parser.result)
print(parser.name)
property brand: List[str]

Accesses the brand property.

Returns:

Brands of parsed items

Return type:

List[str]

property colors: List[List[dict]]

Accesses the color property.

Returns:

Colors of parsed items

Return type:

list[list[dict]]

property feedbacksAmt: List[int]

Accesses the number of feedbacks property.

Returns:

Number of feedbacks of parsed items

Return type:

List[int]

ids: Union[None, List[int], List[str]] = None
property name: List[str]

Accesses the product name property.

Returns:

Product names of parsed items

Return type:

List[str]

parse_data(urls: Union[None, List[str]] = None, ids: Union[None, List[int], List[str]] = None) List[dict]

Parses the data for the products identifiers or/and products pages. The data goes to the result attribute.

Parameters:
  • urls (str, optional) – Product pages to parse, defaults to None

  • ids (str, optional) – Products identifiers, defaults to None

Returns:

List of dicts, each of which contains info about parsed WB items

Return type:

list[dict]

property picsAmt: List[int]

Accesses the pictures amount property.

Returns:

Picture amounts of parsed items

Return type:

List[int]

property priceU: List[int]

Accesses the product price property.

Returns:

Prices of parsed items

Return type:

List[int]

property qty: List[int]

Accesses the qty property.

Returns:

Amount of available products for each parsed item

Return type:

list[int]

property rating: List[float]

Accesses the rating property.

Returns:

Rating values of parsed items

Return type:

List[float]

result: Union[None, List[dict]] = None
property salePriceU: List[int]

Accesses the sale price property.

Returns:

Sale prices of parsed items

Return type:

List[int]

save_data(file_format='json', file_name='goods', encoding='utf-8') None

Creates a file with the selected format and saves the parsing result to it.

Parameters:
  • file_format (str, optional) – One of two possible formats (json or csv), defaults to json

  • file_name (str, optional) – File name, defaults to goods

  • encoding (str, optional) – Encoding type, defaults to utf-8

Returns:

Nothing is returned

Return type:

None

property sizes: List[List[str]]

Accesses the size property.

Returns:

Size values of parsed items

Return type:

list[list[str]]

property supplierId: List[str]

Accesses the supplier identifier property.

Returns:

Supplier identifiers of parsed items

Return type:

List[str]

urls: Union[None, List[str]] = None