jef / streetmerchant

πŸ€– The world's easiest, most powerful stock checker
https://jef.buzz/streetmerchant
MIT License
4.96k stars 1.31k forks source link

Some stores marked as having stock, browser opens, but no stock #1392

Closed simonk83 closed 3 years ago

simonk83 commented 3 years ago

Expected Behavior

These seem to be false positives, so they should be seen as Out of Stock

Current Behavior

Bot marks them as in stock and opens the browser page

Steps to Reproduce

Here's a snippet of the output

[8:55:08 am] info :: β„Ή selected series: 3080, ryzen5900, xboxss
[8:55:20 am] info :: πŸš€πŸš¨ [mwave] [gigabyte (3080)] vision oc :: IN STOCK πŸš¨πŸš€
https://www.mwave.com.au/product/gigabyte-geforce-rtx-3080-vision-oc-10gb-video-card-ac38364
[8:55:20 am] info :: βœ– [cpl] [asus (3080)] strix oc :: OUT OF STOCK
[8:55:22 am] info :: βœ– [centrecom] [asus (3080)] tuf oc :: OUT OF STOCK
[8:55:23 am] info :: βœ– [pccg] [asus (3080)] tuf :: OUT OF STOCK
[8:55:23 am] info :: βœ– [umart] [asus (3080)] strix :: OUT OF STOCK
[8:55:27 am] info :: βœ– [scorptec] [asus (3080)] strix :: OUT OF STOCK
[8:55:28 am] info :: βœ– [cpl] [asus (3080)] tuf :: OUT OF STOCK
[8:55:28 am] info :: βœ– [centrecom] [galax (3080)] sg oc :: OUT OF STOCK
[8:55:28 am] info :: βœ– [umart] [asus (3080)] strix oc :: OUT OF STOCK
[8:55:29 am] info :: πŸš€πŸš¨ [mwave] [gigabyte (3080)] gaming oc :: IN STOCK πŸš¨πŸš€
https://www.mwave.com.au/product/gigabyte-geforce-rtx-3080-gaming-oc-10gb-video-card-ac38091
[8:55:34 am] info :: βœ– [umart] [asus (3080)] tuf :: OUT OF STOCK
[8:55:34 am] info :: βœ– [centrecom] [gigabyte (3080)] aorus master :: OUT OF STOCK
[8:55:35 am] info :: βœ– [pccg] [asus (3080)] tuf oc :: OUT OF STOCK
[8:55:35 am] info :: βœ– [cpl] [asus (3080)] tuf oc :: OUT OF STOCK
[8:55:37 am] info :: βœ– [scorptec] [asus (3080)] strix oc :: OUT OF STOCK
[8:55:37 am] info :: πŸš€πŸš¨ [bpctech] [asus (3080)] tuf :: IN STOCK πŸš¨πŸš€
https://www.bpctech.com.au/tuf-rtx3080-10g-gaming-asus-geforce-rtx-3080-tuf-gaming-10gb-video-card.html
[8:55:38 am] info :: πŸš€πŸš¨ [mwave] [gigabyte (3080)] aorus xtreme :: IN STOCK πŸš¨πŸš€
https://www.mwave.com.au/product/gigabyte-aorus-geforce-rtx-3080-xtreme-10gb-video-card-ac38093

success-1607896520620 success-1607896529456 success-1607896537512 success-1607896538349

Environment

OS: Mac OS Catalina dotenv file:

# ** All configuration variables are optional **
# Copy this file and name it as `dotenv` (without backticks)
# Read https://jef.codes/streetmerchant/getting-started/#customization for help on customizing this file
########################################################################################################

ASCII_BANNER=
ASCII_COLOR=
AUTO_ADD_TO_CART=
BROWSER_TRUSTED=
COUNTRY=
DESKTOP_NOTIFICATIONS=
DISCORD_NOTIFY_GROUP=
DISCORD_NOTIFY_GROUP_3060TI=
DISCORD_NOTIFY_GROUP_3070=
DISCORD_NOTIFY_GROUP_3080=
DISCORD_NOTIFY_GROUP_3090=
DISCORD_NOTIFY_GROUP_CORSAIR_SF=
DISCORD_NOTIFY_GROUP_RX6800=
DISCORD_NOTIFY_GROUP_RX6800XT=
DISCORD_NOTIFY_GROUP_RX6900XT=
DISCORD_NOTIFY_GROUP_RYZEN5600=
DISCORD_NOTIFY_GROUP_RYZEN5800=
DISCORD_NOTIFY_GROUP_RYZEN5900=
DISCORD_NOTIFY_GROUP_RYZEN5950=
DISCORD_NOTIFY_GROUP_SONYPS5C=
DISCORD_NOTIFY_GROUP_SONYPS5DE=
DISCORD_NOTIFY_GROUP_XBOXSX=
DISCORD_NOTIFY_GROUP_XBOXSS=
DISCORD_NOTIFY_GROUP_TEST=
DISCORD_WEB_HOOK=
EMAIL_PASSWORD=
EMAIL_TO=
EMAIL_USERNAME=
HEADLESS=
IN_STOCK_WAIT_TIME=
LOG_LEVEL=
LOW_BANDWIDTH=
MAX_PRICE_SERIES_3060TI=
MAX_PRICE_SERIES_3070=
MAX_PRICE_SERIES_3080=
MAX_PRICE_SERIES_3090=
MAX_PRICE_SERIES_CORSAIR_SF=
MAX_PRICE_SERIES_RX6800=
MAX_PRICE_SERIES_RX6800XT=
MAX_PRICE_SERIES_RX6900XT=
MAX_PRICE_SERIES_RYZEN5600=
MAX_PRICE_SERIES_RYZEN5800=
MAX_PRICE_SERIES_RYZEN5900=
MAX_PRICE_SERIES_RYZEN5950=
MAX_PRICE_SERIES_SONYPS5C=
MAX_PRICE_SERIES_SONYPS5DE=
MAX_PRICE_SERIES_TEST=
MICROCENTER_LOCATION=
MQTT_BROKER_ADDRESS=
MQTT_BROKER_PORT=
MQTT_CLIENT_ID=
MQTT_PASSWORD=
MQTT_QOS=
MQTT_TOPIC=
MQTT_USERNAME=
NVIDIA_ADD_TO_CART_ATTEMPTS=
NVIDIA_SESSION_TTL=
OPEN_BROWSER=
PAGE_BACKOFF_MIN=
PAGE_BACKOFF_MAX=
PAGE_SLEEP_MIN=
PAGE_SLEEP_MAX=
PAGE_TIMEOUT=
PAGERDUTY_INTEGRATION_KEY=
PAGERDUTY_SEVERITY=
PHILIPS_HUE_API_KEY=
PHILIPS_HUE_CLOUD_ACCESS_TOKEN=
PHILIPS_HUE_CLOUD_CLIENT_ID=
PHILIPS_HUE_CLOUD_CLIENT_SECRET=
PHILIPS_HUE_CLOUD_REFRESH_TOKEN=
PHILIPS_HUE_LAN_BRIDGE_IP=
PHILIPS_HUE_LIGHT_COLOR=
PHILIPS_HUE_LIGHT_IDS=
PHILIPS_HUE_LIGHT_PATTERN=
PHONE_CARRIER=
PHONE_NUMBER=
PLAY_SOUND=
PROXY_ADDRESS=
PROXY_PROTOCOL=
PROXY_PORT=
PUSHBULLET=
PUSHOVER_EXPIRE=
PUSHOVER_RETRY=
PUSHOVER_TOKEN=
PUSHOVER_USER=
PUSHOVER_PRIORITY=
SCREENSHOT=
SHOW_ONLY_BRANDS=
SHOW_ONLY_MODELS=
SHOW_ONLY_SERIES=3080,ryzen5900,xboxss
SLACK_CHANNEL=
SLACK_TOKEN=
SMTP_ADDRESS=
SMTP_PORT=
STORES=bpctech,centrecom,cpl,mwave,pccg,scorptec,umart
TELEGRAM_ACCESS_TOKEN=
TELEGRAM_CHAT_ID=
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_FROM_NUMBER=
TWILIO_TO_NUMBER=
TWITCH_ACCESS_TOKEN=
TWITCH_CHANNEL=
TWITCH_CLIENT_ID=
TWITCH_CLIENT_SECRET=
TWITCH_REFRESH_TOKEN=
TWITTER_ACCESS_TOKEN_KEY=
TWITTER_ACCESS_TOKEN_SECRET=
TWITTER_CONSUMER_KEY=
TWITTER_CONSUMER_SECRET=
TWITTER_TWEET_TAGS=
WEB_PORT=34000

Logs

simonk83 commented 3 years ago

Just seems to be those two stores, so I've disabled them for now. The rest are behaving

simonk83 commented 3 years ago

Hmm now it’s doing it for Umart as well

TDCroPower commented 3 years ago

there all is well, you are probably just too slow and the purchase bots faster ;)

jef commented 3 years ago

there all is well, you are probably just too slow and the purchase bots faster ;)

Perhaps, but also the selectors may be off as well πŸ˜€ Did streetmerchant happen to get any screenshots for you? That'll help in debugging.

simonk83 commented 3 years ago

Pretty sure it's not bots, as the stock situation here in Aus is pretty dire and they're not coming in that quickly, plus it's firing off way too many times to be real stock. I did attach some screenshots to the issue above, but here's everything I have from running just now.

If you need me to do any debugging or anything just yell out :)

success-1607987261240 success-1607987269872 success-1607987274748 success-1607987294916 success-1607987303593 success-1607987307486 success-1607987311842 success-1607987321657 success-1607987344691 success-1607987359735 success-1607987370508 success-1607987390533 success-1607987400082 success-1607987404732

simonk83 commented 3 years ago

I had a look at the code for Mwave:

        outOfStock: {
            container: '.stockAndDelivery > li:nth-child(1) > dl > dd',
            text: ['Currently No Stock']
        }
    },

image

I've tried to mess around with this but as my html is non-existent I'm just clutching at straws really. One strange thing though is that this page produces a false positive:

https://www.mwave.com.au/product/asus-geforce-rtx-3080-tuf-gaming-oc-10gb-video-card-ac38205

But this page doesn't:

https://www.mwave.com.au/product/evga-geforce-rtx-3080-ftw3-ultra-gaming-10gb-video-card-ac38322

I can't see a difference in the elements personally, but again I don't really know what I'm doing :)

jef commented 3 years ago

I see the problem. The user agent that it's using was a mobile user agent and the selectors are different for user agents. This needs to get updated.

Thanks!

simonk83 commented 3 years ago

Ah great, happy to do it and push it up if you like as I think it needs to happen for a few of the Aussie ones. I'll see if I can find the right spot, otherwise I'll ask back here ;)

EDIT: Ok maybe it's not as simple as just changing it per store, I see you're using a dynamic user agent switcher. I'll leave it alone (unless it's simple enough, in which case point me in the right direction and I'll see what I can do. I have no html knowledge but I can scrape by with other stuff).

StanZha commented 3 years ago

as mentioned above pages are rendered for mobile device. Selectors are different ui-mobile used 1

no stock found twice 2

this thing works properly for a page opened in desktop browser: .stockAndDelivery > li:nth-child(1) > dl > dd

simonk83 commented 3 years ago

So streetmerchant always uses a mobile user agent? Or it cycles through different agents and sometimes it uses a mobile one? Presumably the latter as that would explain why sometimes it detects properly. If that’s the case it’s probably beyond me to try and fix it to account for both mobile and non mobile, I’ll leave it to the experts πŸ˜„

kin3tik commented 3 years ago

When the store model was submitted the USER_AGENT config item had just been deprecated in favour of a package that pulls in a random user-agent string - is that right @jef ? As per #1335

Am I correct in saying there are two options to fix this?

  1. Add inStock and outOfStock selectors for mobile
  2. Explicitly specify a non-mobile USER_AGENT (is this still possible?)
simonk83 commented 3 years ago

For now I'm using a non-mobile USER_AGENT (so yep, still possible) which has done the trick for mwave, but bpctech is really stubborn and constantly brings up in stock messages regardless, so I assume something else is going on there. They're extra expensive anyway so I've just disabled that store for now.

Also, and this likely can't be helped, but looks like Centrecom are smart and are detecting the activity and blocking IP's pretty quickly.

StanZha commented 3 years ago
  1. I can't tell how useful it is to randomize user agents. In below example it uses weird mix of mobile browsers and desktop browsers across different OS. One of them is chrome 45 on android 4.2, that is very old. I removed all calls to getRandomUserAgent() and got all pages opened properly in desktop mode, at least for test 5 min run against Mwave. When user agent not set explicitly via page.setUserAgent correct user agent for corresponding chromium version will be used. On screenshot every time when user agent for mobile device was used, page was opened in mobile mode and produced false positive. 1_2

  2. It seems second argument for winston logger should be some type of collection. When string passed it prints nothing in console output. I added square brackets and it started printing properly 1_1

StanZha commented 3 years ago

The random-useragent has property deviceType for user agents. If necessary this condition ua.browserName === 'Chrome' && ua.browserVersion > '20' can be modified to exclude mobile and tablet user agents. I don't see single deviceType defined as desktop, so I would assume when deviceType is empty it means desktop: https://github.com/skratchdot/random-useragent/blob/master/useragent-data.json

jef commented 3 years ago

Hey @StanZha, I've updated the user agent library and it's pulling from the top 50 UAs (not mobile). Can you see if this is still an issue for you?

Thanks!


When the store model was submitted the USER_AGENT config item had just been deprecated in favour of a package that pulls in a random user-agent string - is that right @jef ? As per #1335

Am I correct in saying there are two options to fix this?

  1. Add inStock and outOfStock selectors for mobile
  2. Explicitly specify a non-mobile USER_AGENT (is this still possible?)

Yes, that use to be the case, but no longer. Try out the latest and see if you run into any issues.

StanZha commented 3 years ago

Thank you @jef, I tried to run recent code from main for 10 minutes and got all appropriate results - no pages opened in mobile or tablet mode for 3080/mwave store, no false positives observed.

I was just troubleshooting this problem, issue was opened by different user. @simonk83 can you confirm that changes are working as expected?

simonk83 commented 3 years ago

Yep looking good! Thanks Jef

jef commented 3 years ago

Awesome! Thank you for the confirmation 😁