natewong1313 / bird-bot

A Nintendo Switch checkout bot. Currently supports Walmart and Best buy
MIT License
1.18k stars 336 forks source link

[BUG] BestBuy bug Product-Data-Value body-copy is not always defined #42

Open aemperor opened 4 years ago

aemperor commented 4 years ago

Summary:

The array index on line 76 of bestbuy.py causes an error when the product-data-value body-copy is not defined on the browser page. It seems there's some inconsistency with BestBuy's pages.

Error:

[2020-04-28 20:59:13][TASK 8] Error Loading Product Page (line 76 IndexError list index out of range)

Example Page:

https://www.bestbuy.com/site/combo/nintendo-switch-consoles/50fd30b0-690e-4cee-b87e-8f09ad1f85d7

Offending Line:

self.sku_id = doc.xpath('//span[@class="product-data-value body-copy"]/text()')[1].strip()

Offending Line Link:

https://github.com/natewong1313/bird-bot/blob/master/sites/bestbuy.py#L76

5150Joker commented 3 years ago

That bug is there even when the product-data value body-copy is present on the page. For example: https://www.bestbuy.com/site/asus-geforce-rtx-3080-10gb-gddr6x-pci-express-4-0-strix-graphics-card-black/6432445.p?skuId=6432445

AdamOC3 commented 3 years ago

Is there a solution for this?

echocli commented 3 years ago

I know I'm late but try changing line 76 to this self.sku_id = doc.xpath('//div[@class="sku product-data"]//span[@class="product-data-value body-copy"]/text()')[0].strip()

SwiftCODA commented 3 years ago

@echocli Are you located outside of the US? If so, figure out how to use a US proxy. The problem is that the HTML that is returned by the request is actually the page you see when you visit bestbuy.COM if you live in Canada. BestBuy.com sees that you have a Canadian IP and shows you a different page than expected. A US proxy should avoid this.

SwiftCODA commented 3 years ago

Solution is to use a United States Proxy. Please close. @natewong1313