183 lines
9.2 KiB
TypeScript
183 lines
9.2 KiB
TypeScript
// import { getCategoryIdForSlug } from '../categories';
|
|
import { type Product } from './product';
|
|
import { ALL_BRAND_PRODUCTS } from '../brands';
|
|
|
|
/**
|
|
* A list of all the products.
|
|
*/
|
|
export const ALL_PRODUCTS: Product[] = [
|
|
...ALL_BRAND_PRODUCTS
|
|
// {
|
|
// productDetails:
|
|
// }
|
|
// {
|
|
// name: 'Car Phone Mount',
|
|
// description: "Essential for navigation.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ1234',
|
|
// tags: ['phone mount', 'navigation', 'car'],
|
|
// categoryId: getCategoryIdForSeoLink('vehicle-essentials')!,
|
|
// },
|
|
// {
|
|
// name: 'Car Charger',
|
|
// description: "Keep your phone charged during long shifts.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ5678',
|
|
// tags: ['charger', 'car', 'accessory'],
|
|
// categoryId: getCategoryIdForSeoLink('vehicle-essentials')!,
|
|
// },
|
|
// {
|
|
// name: 'Insulated Delivery Bag',
|
|
// description: "Keep food at the right temperature.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ9101',
|
|
// tags: ['delivery bag', 'insulated', 'food'],
|
|
// categoryId: getCategoryIdForSeoLink('delivery-gear')!,
|
|
// },
|
|
// {
|
|
// name: 'Drink Carrier',
|
|
// description: "Securely transport multiple beverages.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ1213',
|
|
// tags: ['drink carrier', 'beverages', 'delivery'],
|
|
// categoryId: getCategoryIdForSeoLink('delivery-gear')!,
|
|
// },
|
|
// {
|
|
// name: 'Portable Phone Charger',
|
|
// description: "Backup power for your phone.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ1415',
|
|
// tags: ['phone charger', 'portable', 'backup'],
|
|
// categoryId: getCategoryIdForSeoLink('personal-items')!,
|
|
// },
|
|
// {
|
|
// name: 'Comfortable Clothing',
|
|
// description: "Weather-appropriate attire.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ1617',
|
|
// tags: ['clothing', 'comfortable', 'weather'],
|
|
// categoryId: getCategoryIdForSeoLink('personal-items')!,
|
|
// },
|
|
// {
|
|
// name: 'Reflective Vest',
|
|
// description: "Increase visibility, especially for night deliveries.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ1819',
|
|
// tags: ['reflective vest', 'safety', 'visibility'],
|
|
// categoryId: getCategoryIdForSeoLink('safety-equipment')!,
|
|
// },
|
|
// {
|
|
// name: 'First Aid Kit',
|
|
// description: "Be prepared for minor injuries.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ2021',
|
|
// tags: ['first aid', 'safety', 'kit'],
|
|
// categoryId: getCategoryIdForSeoLink('safety-equipment')!,
|
|
// },
|
|
// {
|
|
// name: 'Smartphone',
|
|
// description: "Reliable phones with good battery life and performance.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ2223',
|
|
// tags: ['smartphone', 'tech', 'battery life'],
|
|
// categoryId: getCategoryIdForSeoLink('tech-gadgets')!,
|
|
// },
|
|
// {
|
|
// name: 'Bluetooth Headset',
|
|
// description: "For hands-free communication.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ2425',
|
|
// tags: ['bluetooth headset', 'communication', 'hands-free'],
|
|
// categoryId: getCategoryIdForSeoLink('tech-gadgets')!,
|
|
// },
|
|
// {
|
|
// name: 'Bike Lock',
|
|
// description: "Secure your bike while making deliveries.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ2627',
|
|
// tags: ['bike lock', 'security', 'biking'],
|
|
// categoryId: getCategoryIdForSeoLink('biking-gear')!,
|
|
// },
|
|
// {
|
|
// name: 'Bike Lights',
|
|
// description: "For visibility and safety during night rides.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ2829',
|
|
// tags: ['bike lights', 'visibility', 'night'],
|
|
// categoryId: getCategoryIdForSeoLink('biking-gear')!,
|
|
// },
|
|
// {
|
|
// name: 'Portable Cooler',
|
|
// description: "Keep drinks and snacks cold during shifts.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ3031',
|
|
// tags: ['cooler', 'portable', 'convenience'],
|
|
// categoryId: getCategoryIdForSeoLink('comfort-convenience')!,
|
|
// },
|
|
// {
|
|
// name: 'Sunshade',
|
|
// description: "Protect your car's interior and keep it cool.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ3233',
|
|
// tags: ['sunshade', 'car', 'protection'],
|
|
// categoryId: getCategoryIdForSeoLink('comfort-convenience')!,
|
|
// },
|
|
// {
|
|
// name: 'Fitness Tracker',
|
|
// description: "Monitor your activity and health.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ3435',
|
|
// tags: ['fitness tracker', 'health', 'activity'],
|
|
// categoryId: getCategoryIdForSeoLink('health-wellness')!,
|
|
// },
|
|
// {
|
|
// name: 'Healthy Snacks',
|
|
// description: "Convenient, healthy snacks for long shifts.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ3637',
|
|
// tags: ['healthy snacks', 'convenience', 'health'],
|
|
// categoryId: getCategoryIdForSeoLink('health-wellness')!,
|
|
// },
|
|
// {
|
|
// name: 'Flashlight',
|
|
// description: "Handy for night deliveries.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ3839',
|
|
// tags: ['flashlight', 'night', 'deliveries'],
|
|
// categoryId: getCategoryIdForSeoLink('misc')!,
|
|
// },
|
|
// {
|
|
// name: 'Multi-tool',
|
|
// description: "Useful for various minor fixes and adjustments.",
|
|
// amazonLink: 'https://www.amazon.com/dp/B08XYZ4041',
|
|
// tags: ['multi-tool', 'utility', 'fixes'],
|
|
// categoryId: getCategoryIdForSeoLink('misc')!
|
|
// }
|
|
];
|
|
|
|
export function getProductsForCategoryId(categoryId: number) {
|
|
return ALL_PRODUCTS.filter((product) => product.categoryId === categoryId);
|
|
}
|
|
|
|
// import { CheerioCrawler, type CheerioCrawlingContext, log } from 'crawlee';
|
|
// import { extractProductDetails } from '../../scraper/amazon';
|
|
|
|
// /**
|
|
// * Performs the logic of the crawler. It is called for each URL to crawl.
|
|
// * - Passed to the crawler using the `requestHandler` option.
|
|
// */
|
|
// const requestHandler = async (context: CheerioCrawlingContext) => {
|
|
// const { $, request } = context;
|
|
// const { url } = request;
|
|
|
|
// log.info(`Scraping product page`, { url });
|
|
// const extractedProduct = extractProductDetails($);
|
|
|
|
// log.info(`Scraped product details for "${extractedProduct.title}", saving...`, { url });
|
|
// crawler.pushData(extractedProduct);
|
|
|
|
// for (let p = 0; p < allProducts.length; p++) {
|
|
// if (allProducts[p].amazonLink == url) {
|
|
// allProducts[p].amazonProductDetails = extractedProduct;
|
|
// }
|
|
// }
|
|
// };
|
|
|
|
// /**
|
|
// * The crawler instance. Crawlee provides a few different crawlers, but we'll use CheerioCrawler, as it's very fast and simple to use.
|
|
// * - Alternatively, we could use a full browser crawler like `PlaywrightCrawler` to imitate a real browser.
|
|
// */
|
|
// const crawler = new CheerioCrawler({ requestHandler });
|
|
|
|
// // await crawler.run(products.map((p) => p.amazonLink));
|
|
|
|
// await crawler.run([
|
|
// // // // 'https://www.amazon.com/Rubbermaid-Commercial-Deluxe-Cleaning-FG315488BLA/dp/B00006ICOT?crid=23IAS1CUMM6QG&dib=eyJ2IjoiMSJ9.WRH21whjlnubmVRL4HRNIccU9p3CC9B9pvd9LCCkzqxXQggwnV0UNwmgHs868sL9Jr_1cfUHxsHCU7sTT28EMZOCdxoGo-ylie7hWbrQ75ab9SFUJMawaE14LhyNFAQ69j45EtR9kd0njMvXY9WDrBWj61TMpe6K1vl0BC-kWFz8iQqZgrRsgLNN5jbuF83nWOddYMTMZFxQXuvyPUG13LwYmOe17iPUBa03FNecKl0.-fxaqjBgRSTfoIeqegQhb9rz9lE9LJTt475JTTi0J3A&dib_tag=se&keywords=drink+carrier&qid=1719716583&sprefix=drink+carrier,aps,162&sr=8-3&linkCode=sl1&tag=radspazzyspaz-20&linkId=4b1f972cd47168ab215cd7c8fecbefa8&language=en_US&ref_=as_li_ss_tl',
|
|
// // // // 'https://www.amazon.com/dp/B07V3LB5DN?social_share=cm_sw_r_cso_cp_apin_dp_1S8QG7ATMWQXHEPZZJMA&starsLeft=1&fbclid=IwZXh0bgNhZW0CMTEAAR0r1pSlSIglwL42EFH5z3urFfzpT1EnEmxsTc589_C-QjkKpQYBl0m10wc_aem_tfAE9o8HXXadzB6BWVN-Sg&th=1&linkCode=ll1&tag=radspazzyspaz-20&linkId=983adc5be8c6bbb0c0f42676c76b4f6e&language=en_US&ref_=as_li_ss_tl',
|
|
// // 'https://www.amazon.com/Polysteel-600-Waterproof-Flashlight-Stainless/dp/B00SJRDIN2?crid=29BV6TGKIV7U4&dib=eyJ2IjoiMSJ9.z_qqGdUikpKLO62rjeDuDoQDki7kToAVTM2kBLri4vs25y739Ll_nFVMziV7A5ZnYGQQYNujGdg5igViybnULLsVCa_T6qCk9HUVk7GuD30Jp0FrydoVV9zm-m-E9Zhi7vGbjJdDxUmYXypCL_GaGT6O6K4gf2P94QITVfbbBrjNT74VL9ZdRfs9ucPUSjkoTNLCMXcAXf4fXnJqniXk4PyFks_YYcZ9K8IDN4Fp-puEBc5lhdIp2hY4ugsmMD2v9zYNTvaTD1EaAnXVA_UXIrGwSTdg3Q2cWoqWF6sw6mo.z0JvreFTZ58D14a2IuwCSDybpR9x_CTUBSRrNlP9aZs&dib_tag=se&keywords=coast+flash+light&qid=1720695258&s=sporting-goods&sprefix=coast+flash+light%2Csporting%2C83&sr=1-27&linkCode=ll1&tag=dashersupply-20&linkId=9cfd6086ba43fac649f6884f72c7c844&language=en_US&ref_=as_li_ss_tl',
|
|
// 'https://www.amazon.com/First-Aid-Only-Weatherproof-Plastic/dp/B001SG76MU?crid=17746AVZ2R4TK&dib=eyJ2IjoiMSJ9.nehq12VwBTB17Vyx1YODXq7JYQbnOM8xv6AZRadSceLpsk33o-ES3M7UnJMkq0usrVmB1uKgdw9rxtPf7wcS1fHI_DhXIkjp7ujnBf0xvt-SjW3Xw__yU6NvYnSUmSfQzcqj49ZMu893KSypCAIPiLZ0gHo9HbRPicFsuJVBOCv5aOQoBqlLRymArai_8k9lUwtCxAfhfiDjUGk6K3s_S6IFWUP88Ff8mbyU5lkVRtbE4dRTCp-wNjM6HpxqZPSZ0A3_-PPl75PlgjsmUXIkxArreEPatqaHwyJ13X-DCQU.CWOEqmjYxSJ7yRXLCgtz9iGOSGJD53MSoPw6jzAWx7Q&dib_tag=se&keywords=first+aid+kit&qid=1720746463&sprefix=first+aid+kit%2Caps%2C95&sr=8-3-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&psc=1&linkCode=ll1&tag=dashersupply-20&linkId=385f21e08641ef9ce7ad55aebe2d30cf&language=en_US&ref_=as_li_ss_tl',
|
|
// ]);
|