Streetmerchant: CORSAIR SFX Problems - False postive in stock (newegg.com), Ignores Max Price (amazon.com)

Created on 24 Nov 2020  路  6Comments  路  Source: jef/streetmerchant

Description

Trying out the new Corsair SF 750 watt and I get constant in-stock hits for both newegg.com and amazon.com.

Newegg opens a browser that leads to a page saying something like "This item is actually out of stock. Would you like to 1. Auto Notify, 2. Save for later"

I've set in my .env MAX_PRICE_CORSAIR_SF="190" but with amazon I get an in stock alert and an browser launch with a "Confirm you want this item added to your cart" with a price of $277.99.

bug

Most helpful comment

Wrote a quick helper function that allows you to have array's for containers (for max price). Using this in my build atm.

Just need to adjust some types. (this goes in store/includes-labels.ts)

export async function getCardPrice(page: Page, query: Pricing, options: Selector): Promise<string | null> {
  const selector = query.container
  if (typeof selector === 'string') {
    return await extractPageContents(page, {...options, selector});
  }
  for (let index = 0; index < selector.length; index++) {
    const cardPrice = await extractPageContents(page, {...options, selector: selector[index]});
    if (cardPrice) {
      return cardPrice
    }
  }
  return null
}

And is called like (in the same file):

export async function cardPrice(
  page: Page,
  query: Pricing,
  max: number,
  options: Selector
): Promise<number | null> {
  if (!max || max === -1) {
    return null;
  }
  const cardPrice = await getCardPrice(page, query, options)

  if (cardPrice) {
    const priceSeperator = query.euroFormat ? /\./g : /,/g;
    const cardpriceNumber = Number.parseFloat(
      cardPrice.replace(priceSeperator, '').match(/\d+/g)!.join('.')
    );

    logger.debug(`Raw card price: ${cardPrice} | Limit: ${max}`);
    return cardpriceNumber > max ? cardpriceNumber : null;
  }

  return null;
}

This config allows you to just do this in a store:

maxPrice: {
  container: ['span[class*="PriceString"]', 'span[class*="offer-price"]', 'span[class*="a-color-price"]']
},

All 6 comments

I'm also getting a false positive In Stock alert for a used 3070 on Amazon that's over the MAX_PRICE.

+1. Also getting the same false positive. fyi this is because the selector string changes for used items:

Normal:
container: 'span[class*="PriceString"]

Used:
container: 'span[class*="offer-price"]

would be nice to be able to specify both.

Wrote a quick helper function that allows you to have array's for containers (for max price). Using this in my build atm.

Just need to adjust some types. (this goes in store/includes-labels.ts)

export async function getCardPrice(page: Page, query: Pricing, options: Selector): Promise<string | null> {
  const selector = query.container
  if (typeof selector === 'string') {
    return await extractPageContents(page, {...options, selector});
  }
  for (let index = 0; index < selector.length; index++) {
    const cardPrice = await extractPageContents(page, {...options, selector: selector[index]});
    if (cardPrice) {
      return cardPrice
    }
  }
  return null
}

And is called like (in the same file):

export async function cardPrice(
  page: Page,
  query: Pricing,
  max: number,
  options: Selector
): Promise<number | null> {
  if (!max || max === -1) {
    return null;
  }
  const cardPrice = await getCardPrice(page, query, options)

  if (cardPrice) {
    const priceSeperator = query.euroFormat ? /\./g : /,/g;
    const cardpriceNumber = Number.parseFloat(
      cardPrice.replace(priceSeperator, '').match(/\d+/g)!.join('.')
    );

    logger.debug(`Raw card price: ${cardPrice} | Limit: ${max}`);
    return cardpriceNumber > max ? cardpriceNumber : null;
  }

  return null;
}

This config allows you to just do this in a store:

maxPrice: {
  container: ['span[class*="PriceString"]', 'span[class*="offer-price"]', 'span[class*="a-color-price"]']
},

+1. Also getting the same false positive. fyi this is because the selector string changes for used items:

Normal:
container: 'span[class*="PriceString"]

Used:
container: 'span[class*="offer-price"]

would be nice to be able to specify both.

You think folks would be interested in used items as well?

Also, feel free to make a PR for going through a list of containers! Seems like a great addition.

had a similar request, would be really great if someone puts it together and then fixes :)

see #1500

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AlphaOmega2020 picture AlphaOmega2020  路  4Comments

scot-onet picture scot-onet  路  4Comments

fabillopr picture fabillopr  路  3Comments

zhirzzh picture zhirzzh  路  5Comments

millionhari picture millionhari  路  5Comments