Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated cart count index and response parse #21

Merged
merged 1 commit into from
Sep 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def add_to_cart(self, url: str) -> int:
add_to_card_button.click()

sleep(1)
return int(self._driver.find_elements(By.CLASS_NAME, "tsCaptionBold")[-1].text)
return int(self._driver.find_elements(By.CLASS_NAME, "tsCaptionBold")[3].text)

def get_cart(self) -> Collection[Item]:
logger.debug("Getting cart...")
Expand Down Expand Up @@ -98,7 +98,7 @@ def get_cart(self) -> Collection[Item]:
def _parse_cart_json(response_json, cart_id: str) -> Iterable[Item]:
logger.debug("Parsing cart json...")

cart_json: str = response_json.get("trackingPayloads").get(cart_id)
cart_json: str = response_json.get("state").get("trackingPayloads").get(cart_id)
items_json = json.loads(cart_json).get("items")

items: list[Item] = []
Expand Down