add gitignore

main
saif 2025-01-01 11:54:45 +05:00
commit 278b2462d6
17 changed files with 98006 additions and 0 deletions

6
.env Normal file
View File

@ -0,0 +1,6 @@
ENVIRONMENT=dev
email=da92149f001b27bed23292ba08a62580baa62eccf3765811d7f86bfa921d062f
password=a43b0d49b42261f4f412a37b3bf022fe
totp=C6QEEEGE23DPNMCT3R5JZ46HOU4SWEY7R7ACJ3VVAXZRO7UTLRGA
temu-email=f1469474d58398bc5033a2daeab39d5f9f1bf52de293f9554c2f3c516ff1d007
temu-password=d7964f37824ee3c0a55d4d752007fab5

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules/

40
config.json Normal file
View File

@ -0,0 +1,40 @@
{
"dev": {
"temu_orders_path" : "D:/Projects/Crawlers/temu-label-crawler",
"orders_path": "D:/Projects/Crawlers/amazon_crawler/data/orders",
"voc_path":"D:/Projects/Crawlers/amazon_crawler/data/voc",
"reviews_path": "D:/Projects/Crawlers/amazon_crawler/data/reviews",
"return_comments_path": "D:/Projects/Crawlers/amazon_crawler/data/return_comments",
"storefront_path": "D:/Projects/Crawlers/amazon_crawler/data/storefront",
"chrome_profile_path": "D:/Projects/Crawlers/amazon_crawler/data/chrome_path",
"cosmos_path_orders_progress": "http://localhost:8080/uind/rest/cosmos/amazon-orders-progress/edit",
"cosmos_path_vocs" : "https://portal.utopiaindustries.pk/uind/rest/cosmos/amazon-voc/edit",
"localhost_return_comments_path":"http://192.168.91.11:8080/uind/rest/cosmos/amazon-voc/return-comments/edit",
"cosmos_path_reviews" : "https://portal.utopiaindustries.pk/uind/rest/cosmos/amazon-reviews/edit",
"cosmos_temu_orders" : "http://192.168.90.228:8081/cosmos/temu/order-upload-json",
"shopify_products_path" : "D:/Projects/Crawlers/amazon_crawler/data/products",
"shopify_variants_path" : "D:/Projects/Crawlers/amazon_crawler/data/variants",
"amz_product_path" : "D:/Projects/Crawlers/amazon_crawler/data/products",
"temuLoginPage" : "https://seller.temu.com/login.html",
"temuOrdersPage" : "https://seller.temu.com/orders.html?activeTab=2",
"temuOrderPage" : "https://seller.temu.com/order-detail.html?parent_order_sn=",
"temuOrderReportPage" : "https://seller.temu.com/order-reports.html"
},
"prod": {
"temu_orders_path" : "/mnt/AmazonReports/Temu",
"orders_path": "/mnt/AmazonReports/amazon-orders",
"voc_path": "/mnt/AmazonReports/amazon-voc",
"reviews_path": "/mnt/AmazonReports/amazon-reviews",
"return_comments_path": "/mnt/AmazonReports/return_comments",
"storefront_path": "/mnt/AmazonReports/amazon-storefront",
"chrome_profile_path": "/home/ec2-user/amazon_crawler/chrome_profile",
"cosmos_path_orders_progress": "https://portal.utopiaindustries.pk/uind/rest/cosmos/amazon-orders-progress/edit",
"cosmos_path_vocs" : "https://portal.utopiaindustries.pk/uind/rest/cosmos/amazon-voc/edit",
"cosmos_path_reviews" : "https://portal.utopiaindustries.pk/uind/rest/cosmos/amazon-reviews/edit",
"cosmos_temu_orders" : "https://cosmos.utopiadeals.com/cosmos/temu/order-upload-json",
"temuLoginPage" : "https://seller.temu.com/login.html",
"temuOrdersPage" : "https://seller.temu.com/orders.html?activeTab=2",
"temuOrderPage" : "https://seller.temu.com/order-detail.html?parent_order_sn=",
"temuOrderReportPage" : "https://seller.temu.com/order-reports.html"
}
}

198
cookies/cookies.json Normal file
View File

@ -0,0 +1,198 @@
[
{
"name": "b_uin",
"value": "BTTBCF2WB3OMAZECPIKE6MKAXI4OU7EVQM6PELRHGJR46557J6ODHADFGOEJVAGRXCH65H33ADGRPJKC2PSW5MLX7TTVCUQ",
"domain": ".seller.temu.com",
"path": "/",
"expires": 1736244526.528562,
"size": 100,
"httpOnly": true,
"secure": true,
"session": false,
"priority": "Medium",
"sameParty": false,
"sourceScheme": "Secure"
},
{
"name": "HISTORY_ACCOUNT_TICKET",
"value": "MFRDEMLGG5TGKMDFHE4DSNJRMM2WINJUGUZGIYRUMQ3DGNRZGFRDMNBWMYZDIYRSG4ZTQZLCGJRWKNDDGVQTAZLBMNSGCMBVGY4TSY3CG4",
"domain": ".seller.temu.com",
"path": "/",
"expires": 1736244526.52848,
"size": 128,
"httpOnly": true,
"secure": true,
"session": false,
"priority": "Medium",
"sameParty": false,
"sourceScheme": "Secure"
},
{
"name": "_bee",
"value": "Ex3V4aoQmdxzIzVHyTsWEYcZvGQSsapj",
"domain": ".temu.com",
"path": "/",
"expires": 1767175726.085074,
"size": 36,
"httpOnly": false,
"secure": true,
"session": false,
"priority": "Medium",
"sameParty": false,
"sourceScheme": "Secure"
},
{
"name": "dilx",
"value": "1biXgahvSrTyQ2nJRbyYd",
"domain": ".temu.com",
"path": "/",
"expires": 1767175726.08524,
"size": 25,
"httpOnly": true,
"secure": true,
"session": false,
"priority": "Medium",
"sameParty": false,
"sourceScheme": "Secure"
},
{
"name": "region",
"value": "0",
"domain": "seller.temu.com",
"path": "/",
"expires": -1,
"size": 7,
"httpOnly": false,
"secure": true,
"session": true,
"priority": "Medium",
"sameParty": false,
"sourceScheme": "Secure"
},
{
"name": "seller_site",
"value": "100",
"domain": "seller.temu.com",
"path": "/",
"expires": 1738231726.812448,
"size": 14,
"httpOnly": false,
"secure": true,
"session": false,
"priority": "Medium",
"sameParty": false,
"sourceScheme": "Secure"
},
{
"name": "hfsc",
"value": "L3yJfYky6jb81JDKfQ==",
"domain": ".temu.com",
"path": "/",
"expires": 1767175726.08527,
"size": 24,
"httpOnly": true,
"secure": true,
"session": false,
"priority": "Medium",
"sameParty": false,
"sourceScheme": "Secure"
},
{
"name": "MALL_ID",
"value": "635517729287890",
"domain": ".seller.temu.com",
"path": "/",
"expires": 1735726126.812385,
"size": 22,
"httpOnly": true,
"secure": true,
"session": false,
"priority": "Medium",
"sameParty": false,
"sourceScheme": "Secure"
},
{
"name": "_nano_fp",
"value": "Xpmqnp9xXqCYn5dan9_6~4uR6yKnKyo27XJwbXxn",
"domain": "seller.temu.com",
"path": "/",
"expires": 1766559846,
"size": 48,
"httpOnly": false,
"secure": true,
"session": false,
"priority": "Medium",
"sameParty": false,
"sourceScheme": "Secure"
},
{
"name": "seller_timezone",
"value": "Asia%2FKarachi",
"domain": "seller.temu.com",
"path": "/",
"expires": 1767175728.02715,
"size": 29,
"httpOnly": false,
"secure": true,
"session": false,
"priority": "Medium",
"sameParty": false,
"sourceScheme": "Secure"
},
{
"name": "api_uid",
"value": "Cp13kmdtH2x0PwBBS/KlAg==",
"domain": ".temu.com",
"path": "/",
"expires": 1766740716.556744,
"size": 31,
"httpOnly": false,
"secure": true,
"session": false,
"priority": "Medium",
"sameParty": false,
"sourceScheme": "Secure"
},
{
"name": "OS_SELLER_PASS_ID",
"value": "TFLY6FCR5HUYYZFXAJW5FNKBQQBT4GVHNRKWDRJ3RYTUVLPR2WSW6BS446BRZZVJCHFRB6O2Q4HAD5QINVWWED5LORYPXEQ5A3NDVZAHX5JA0010648ecf8735",
"domain": ".seller.temu.com",
"path": "/",
"expires": 1736244526.528544,
"size": 139,
"httpOnly": true,
"secure": true,
"session": false,
"priority": "Medium",
"sameParty": false,
"sourceScheme": "Secure"
},
{
"name": "seller_language",
"value": "en",
"domain": "seller.temu.com",
"path": "/",
"expires": 1737615845.95347,
"size": 17,
"httpOnly": false,
"secure": true,
"session": false,
"priority": "Medium",
"sameParty": false,
"sourceScheme": "Secure"
},
{
"name": "njrpl",
"value": "Ex3V4aoQmdxzIzVHyTsWEYcZvGQSsapj",
"domain": ".temu.com",
"path": "/",
"expires": 1767175726.0852,
"size": 37,
"httpOnly": true,
"secure": true,
"session": false,
"priority": "Medium",
"sameParty": false,
"sourceScheme": "Secure"
}
]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,521 @@
[
{
"order_id": "PO-211-20082395387433834",
"order_status": "Canceled",
"order_item_id": "211-20082374415913834",
"order_item_status": "Canceled",
"product_name": "Utopia Bedding 100% Waterproof Mattress Encasement Zippered - Bed Bug Proof Mattress Protector - Absorbent, Six-Sided Mattress Cover",
"variation": "Twin (39 x 75 Inches)",
"contribution_sku": "UBCFKENCASEMENTMATTRESSTWIN10-UB1201",
"sku_id": 48775796109117,
"quantity_purchased": 2,
"quantity_shipped": 0,
"quantity_to_ship": 0,
"purchase_date": "Dec 27, 2024, 12:52 am PKT",
"latest_shipping_time": "Dec 29, 2024, 12:09 pm PKT",
"latest_delivery_time": "Jan 5, 2025, 10:59 am PKT",
"activity_goods_base_price": 8.55,
"base_price_total": 9.5
},
{
"order_id": "PO-211-20082395387433834",
"order_status": "Canceled",
"order_item_id": "211-20082366551593834",
"order_item_status": "Canceled",
"product_name": "Utopia Bedding 100% Waterproof Mattress Encasement Zippered - Bed Bug Proof Mattress Protector - Absorbent, Six-Sided Mattress Cover",
"variation": "Full (54 x 75 Inches)",
"contribution_sku": "UBCFKENCASEMENTMATTRESSFULL10-UB1202",
"sku_id": 41113574480683,
"quantity_purchased": 3,
"quantity_shipped": 0,
"quantity_to_ship": 0,
"purchase_date": "Dec 27, 2024, 12:52 am PKT",
"latest_shipping_time": "Dec 29, 2024, 12:09 pm PKT",
"latest_delivery_time": "Jan 5, 2025, 10:59 am PKT",
"activity_goods_base_price": 11.97,
"base_price_total": 13.3
},
{
"order_id": "PO-211-20149696451112123",
"order_status": "Shipped",
"order_item_id": "211-20149691208232123",
"order_item_status": "Shipped",
"product_name": "Utopia Towels 8 Premium Towels, 2 Bath Towels, 2 Hand Towels, and 4 Wash Cloths, Highly Absorbent 600 GSM 100% Ring Spun Cotton Towels for Bathroom, Hotel, Spa, Gym",
"variation": "Plum",
"contribution_sku": "UTSLTOWELSETPLUM2",
"sku_id": 48114371175913,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"recipient_name": "Adelia Chambers",
"recipient_first_name": "Adelia",
"recipient_last_name": "Chambers",
"recipient_phone_number": "13145302267-0437",
"ship_address_1": "217 Avalone Dr",
"ship_city": "APOPKA",
"ship_state": "FL",
"ship_postal_code": "32703-4609",
"ship_country_": "United States",
"purchase_date": "Dec 27, 2024, 1:16 am PKT",
"latest_shipping_time": "Dec 29, 2024, 10:30 am PKT",
"latest_delivery_time": "Jan 5, 2025, 9:59 am PKT",
"virtual_email": "2zeua6thus120b9@us.shipping.temuemail.com",
"activity_goods_base_price": 18.5,
"base_price_total": 24.1,
"tracking_number": "1ZH934B6YW24924551",
"carrier": "UPS",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-20106890563112376",
"order_status": "Shipped",
"order_item_id": "211-20106848620072376",
"order_item_status": "Shipped",
"product_name": "NY Threads Men Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe",
"variation": "Navy / Large/X-Large",
"contribution_sku": "NYTBATHROBEMENHOODNAVYL/XL",
"sku_id": 38158636960077,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"recipient_name": "Frances Robinson",
"recipient_phone_number": "13145570888-7219",
"ship_address_1": "9103 Bay Port Cir",
"ship_city": "INDIANAPOLIS",
"ship_state": "IN",
"ship_postal_code": "46236-9343",
"ship_country_": "United States",
"purchase_date": "Dec 27, 2024, 1:10 am PKT",
"latest_shipping_time": "Dec 29, 2024, 10:30 am PKT",
"latest_delivery_time": "Jan 5, 2025, 9:59 am PKT",
"virtual_email": "6gnehmo5vm12056@us.shipping.temuemail.com",
"activity_goods_base_price": 15.11,
"base_price_total": 20.7,
"tracking_number": 61290359305349930000,
"carrier": "FedEx",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-20524199414310179",
"order_status": "Shipped",
"order_item_id": "211-20524237425190179",
"order_item_status": "Shipped",
"product_name": "NY Threads Women's Flannel Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe",
"variation": "Burgundy / Small",
"contribution_sku": "NYTBATHROBEWOMENHOODBURGUNDYS",
"sku_id": 44480828840124,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"recipient_name": "Carole LaRue",
"recipient_phone_number": "13145499797-6824",
"ship_address_1": "105 Ravenswood Court",
"ship_city": "PETALUMA",
"ship_state": "CA",
"ship_postal_code": 94952,
"ship_country_": "United States",
"purchase_date": "Dec 27, 2024, 1:14 am PKT",
"latest_shipping_time": "Dec 29, 2024, 3:13 pm PKT",
"latest_delivery_time": "Jan 5, 2025, 12:59 pm PKT",
"virtual_email": "vkob5rju3m1207e@us.shipping.temuemail.com",
"activity_goods_base_price": 12.99,
"base_price_total": 14.99,
"tracking_number": 61290359305349930000,
"carrier": "FedEx",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-20055047634473999",
"order_status": "Shipped",
"order_item_id": "211-20055026662953999",
"order_item_status": "Shipped",
"product_name": "Utopia Towels 8 Premium Towels, 2 Bath Towels, 2 Hand Towels, and 4 Wash Cloths, Highly Absorbent 600 GSM 100% Ring Spun Cotton Towels for Bathroom, Hotel, Spa, Gym",
"variation": "Black",
"contribution_sku": "UTSLTOWELSETBLACK4",
"sku_id": 37351183150205,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"recipient_name": "Kasper Gautier",
"recipient_first_name": "Kasper",
"recipient_last_name": "Gautier",
"recipient_phone_number": "13145301849-0304",
"ship_address_1": "1000 Watermark Pl",
"ship_address_2": 511,
"ship_city": "COLUMBIA",
"ship_state": "SC",
"ship_postal_code": "29210-8232",
"ship_country_": "United States",
"purchase_date": "Dec 27, 2024, 1:24 am PKT",
"latest_shipping_time": "Dec 29, 2024, 10:30 am PKT",
"latest_delivery_time": "Jan 5, 2025, 9:59 am PKT",
"virtual_email": "ssjjaj3bde120f0@us.shipping.temuemail.com",
"activity_goods_base_price": 18.5,
"base_price_total": 32,
"tracking_number": 61290359305349930000,
"carrier": "FedEx",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-20162713917992077",
"order_status": "Shipped",
"order_item_id": "211-20162734889512077",
"order_item_status": "Shipped",
"product_name": "NY Threads Men Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe",
"variation": "Navy / 2X-Large/3XLarge",
"contribution_sku": "NYTBATHROBEMENHOODNAVY2XL3XL",
"sku_id": 43415676913835,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"recipient_name": "Cheryl Short",
"recipient_phone_number": "13145497921-2246",
"ship_address_1": "4432 Spring Blossom Dr",
"ship_city": "KISSIMMEE",
"ship_state": "FL",
"ship_postal_code": "34746-2302",
"ship_country_": "United States",
"purchase_date": "Dec 27, 2024, 12:54 am PKT",
"latest_shipping_time": "Dec 29, 2024, 10:30 am PKT",
"latest_delivery_time": "Jan 5, 2025, 9:59 am PKT",
"virtual_email": "rf6zikjg2t120e4@us.shipping.temuemail.com",
"activity_goods_base_price": 14.52,
"base_price_total": 19.9,
"tracking_number": "1ZH934B6YW21059019",
"carrier": "UPS",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-20389450243112004",
"order_status": "Shipped",
"order_item_id": "211-20389502671912004",
"order_item_status": "Shipped",
"product_name": "Utopia Bedding 4 Piece Bedding Set - Fade & Shrinkage Resistant Brushed Microfiber - Easy Care",
"variation": "Navy / King",
"contribution_sku": "UB0260-UBMICROFIBER4PCKINGNAVY",
"sku_id": 43278237966822,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"recipient_name": "Sonia Daly",
"recipient_first_name": "Sonia",
"recipient_last_name": "Daly",
"recipient_phone_number": "13145300856-6585",
"ship_address_1": "4440 Danny R Wimberly Dr apt 39",
"ship_address_2": 39,
"ship_city": "SHREVEPORT",
"ship_state": "LA",
"ship_postal_code": 71119,
"ship_country_": "United States",
"purchase_date": "Dec 27, 2024, 12:10 am PKT",
"latest_shipping_time": "Dec 29, 2024, 11:30 am PKT",
"latest_delivery_time": "Jan 5, 2025, 10:59 am PKT",
"virtual_email": "gc73zngziv1205f@us.shipping.temuemail.com",
"base_price_total": 13.15,
"tracking_number": "1ZH934B6YW36710189",
"carrier": "UPS",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-20533522253350891",
"order_status": "Shipped",
"order_item_id": "211-20533616625190891",
"order_item_status": "Shipped",
"product_name": "NY Threads Women's Flannel Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe",
"variation": "Black / Small",
"contribution_sku": "NYTBATHROBEWOMENHOODBLACKS",
"sku_id": 48346299418388,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"recipient_name": "Barbara Tuson",
"recipient_phone_number": "13145301849-6211",
"ship_address_1": "2619 W Latrobe St",
"ship_address_2": "house",
"ship_city": "PEORIA",
"ship_state": "IL",
"ship_postal_code": "61605-1451",
"ship_country_": "United States",
"purchase_date": "Dec 27, 2024, 1:29 am PKT",
"latest_shipping_time": "Dec 29, 2024, 11:30 am PKT",
"latest_delivery_time": "Jan 5, 2025, 10:59 am PKT",
"virtual_email": "hpokbsbs6w120ae@us.shipping.temuemail.com",
"activity_goods_base_price": 12.99,
"base_price_total": 14.99,
"tracking_number": "1ZH934B6YW34387024",
"carrier": "UPS",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-19990411766313102",
"order_status": "Shipped",
"order_item_id": "211-19990470748713102",
"order_item_status": "Shipped",
"product_name": "Bed Furniture Risers - Set of 8 pcs (4 x 3 Inch & 4 x 5 Inch) Heavy Duty Bed Risers - Supports 1300 Lbs - Can Be Combined To Make 4 x 8 Inch Riser",
"variation": "Brown",
"contribution_sku": "UBFURNITURERISERBROWN",
"sku_id": 37471442215596,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"recipient_name": "Laura Sanburn",
"recipient_phone_number": "13145499781-3411",
"ship_address_1": "14607 Highland Rdg",
"ship_city": "SAN ANTONIO",
"ship_state": "TX",
"ship_postal_code": "78233-3855",
"ship_country_": "United States",
"purchase_date": "Dec 27, 2024, 12:58 am PKT",
"latest_shipping_time": "Dec 29, 2024, 11:30 am PKT",
"latest_delivery_time": "Jan 5, 2025, 10:59 am PKT",
"virtual_email": "jflmcmgqdi12038@us.shipping.temuemail.com",
"activity_goods_base_price": 10,
"base_price_total": 12.28,
"tracking_number": "1ZH934B6YW17689141",
"carrier": "UPS",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-20152340442152139",
"order_status": "Shipped",
"order_item_id": "211-20152324713512139",
"order_item_status": "Shipped",
"product_name": "Utopia Bedding All-Season Down Alternative Comforter - Light Weight Plush Duvet Insert with Siliconized Fiberfill and Box Stitching",
"variation": "White / Queen (88 x 88 Inches)",
"contribution_sku": "UBCOMFORTERLIGHTWEIGHTQUEENWHITE-UB0060",
"sku_id": 42204496181519,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"recipient_name": "Bonnie Harro",
"recipient_phone_number": "13145300294-2981",
"ship_address_1": "4816 O Ct NE",
"ship_city": "AUBURN",
"ship_state": "WA",
"ship_postal_code": "98002-1229",
"ship_country_": "United States",
"purchase_date": "Dec 27, 2024, 1:00 am PKT",
"latest_shipping_time": "Dec 29, 2024, 1:30 pm PKT",
"latest_delivery_time": "Jan 5, 2025, 12:59 pm PKT",
"virtual_email": "wz72i4w23j12084@us.shipping.temuemail.com",
"activity_goods_base_price": 16.38,
"base_price_total": 18.2,
"tracking_number": 61290359305349930000,
"carrier": "FedEx",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-20060053786153681",
"order_status": "Shipped",
"order_item_id": "211-20060038057513681",
"order_item_status": "Shipped",
"product_name": "Utopia Bedding 100% Waterproof Mattress Encasement Zippered - Bed Bug Proof Mattress Protector - Absorbent, Six-Sided Mattress Cover",
"variation": "King (78 x 80 Inches)",
"contribution_sku": "UBCFKENCASEMENTMATTRESSKING-UB0034",
"sku_id": 52211769976359,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"recipient_name": "Letty Mijares",
"recipient_phone_number": "13145301816-1088",
"ship_address_1": "1929 SE 8th Ter",
"ship_city": "CAPE CORAL",
"ship_state": "FL",
"ship_postal_code": "33990-1636",
"ship_country_": "United States",
"purchase_date": "Dec 27, 2024, 1:07 am PKT",
"latest_shipping_time": "Dec 29, 2024, 10:30 am PKT",
"latest_delivery_time": "Jan 5, 2025, 9:59 am PKT",
"virtual_email": "uograjkcxo120c7@us.shipping.temuemail.com",
"activity_goods_base_price": 14,
"base_price_total": 16.7,
"tracking_number": "1ZH934B6YW08608227",
"carrier": "UPS",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-20335640893991047",
"order_status": "Shipped",
"order_item_id": "211-20335651379751047",
"order_item_status": "Shipped",
"product_name": "Utopia Kitchen 12 & 24 Pack - 28 x 28 Inches Flour Sack Towels 100% Cotton Cleaning & Drying Tea Towels - Highly Absorbent Dish Towels",
"variation": "Beige / 12 Pack",
"contribution_sku": "UKFLOURSACK12-BEIGE-UK0534",
"sku_id": 39842264180714,
"quantity_purchased": 2,
"quantity_shipped": 2,
"quantity_to_ship": 0,
"recipient_name": "Susan Hisgen",
"recipient_phone_number": "13145303633-2427",
"ship_address_1": "1003 Hacienda Drive",
"ship_city": "SUN CITY CENTER",
"ship_state": "FL",
"ship_postal_code": 33573,
"ship_country_": "United States",
"purchase_date": "Dec 27, 2024, 12:26 am PKT",
"latest_shipping_time": "Dec 29, 2024, 10:30 am PKT",
"latest_delivery_time": "Jan 5, 2025, 9:59 am PKT",
"virtual_email": "6hllnq73ft12002@us.shipping.temuemail.com",
"activity_goods_base_price": 10.92,
"base_price_total": 11.5,
"tracking_number": "1ZH934B6YW39992156",
"carrier": "UPS",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-20163906481192068",
"order_status": "Shipped",
"order_item_id": "211-20163890752552068",
"order_item_status": "Shipped",
"product_name": "Utopia Bedding 100% Waterproof Mattress Encasement Zippered - Bed Bug Proof Mattress Protector - Absorbent, Six-Sided Mattress Cover",
"variation": "Queen (60 x 80 Inches)",
"contribution_sku": "UBCFKENCASEMENTMATTRESSQUEEN10-UB1205",
"sku_id": 49995566843268,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"recipient_name": "Tyler Estep",
"recipient_first_name": "Tyler",
"recipient_last_name": "Estep",
"recipient_phone_number": "13145300344-6065",
"ship_address_1": "400 Pecan Ln",
"ship_city": "SOMERVILLE",
"ship_state": "TX",
"ship_postal_code": "77879-5564",
"ship_country_": "United States",
"purchase_date": "Dec 27, 2024, 1:35 am PKT",
"latest_shipping_time": "Dec 29, 2024, 5:13 pm PKT",
"latest_delivery_time": "Jan 5, 2025, 10:59 am PKT",
"virtual_email": "fvk5pcmc761209f@us.shipping.temuemail.com",
"activity_goods_base_price": 12,
"base_price_total": 13.99,
"tracking_number": "1ZH934B6YW28568135",
"carrier": "UPS",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-20543579238950831",
"order_status": "Delivered",
"order_item_id": "211-20543571374630831",
"order_item_status": "Delivered",
"product_name": "Bed Furniture Risers - Set of 8 pcs (4 x 3 Inch & 4 x 5 Inch) Heavy Duty Bed Risers - Supports 1300 Lbs - Can Be Combined To Make 4 x 8 Inch Riser",
"variation": "Brown",
"contribution_sku": "UBFURNITURERISERBROWN",
"sku_id": 37471442215596,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"purchase_date": "Dec 27, 2024, 12:37 am PKT",
"latest_shipping_time": "Dec 29, 2024, 10:30 am PKT",
"latest_delivery_time": "Jan 5, 2025, 9:59 am PKT",
"activity_goods_base_price": 10,
"base_price_total": 12.28,
"tracking_number": 61290359305349930000,
"carrier": "FedEx",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-20461558684710262",
"order_status": "Delivered",
"order_item_id": "211-20461540334630262",
"order_item_status": "Delivered",
"product_name": "NY Threads Women's Flannel Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe",
"variation": "Black / Large",
"contribution_sku": "NYTBATHROBEWOMENHOODBLACKL",
"sku_id": 44858785940399,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"purchase_date": "Dec 27, 2024, 1:18 am PKT",
"latest_shipping_time": "Dec 29, 2024, 10:30 am PKT",
"latest_delivery_time": "Jan 5, 2025, 9:59 am PKT",
"activity_goods_base_price": 12.99,
"base_price_total": 14.99,
"tracking_number": 61290359305349940000,
"carrier": "FedEx",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-20319235215911142",
"order_status": "Delivered",
"order_item_id": "211-20319258808871142",
"order_item_status": "Delivered",
"product_name": "Bed Furniture Risers - Set of 8 pcs (4 x 3 Inch & 4 x 5 Inch) Heavy Duty Bed Risers - Supports 1300 Lbs - Can Be Combined To Make 4 x 8 Inch Riser",
"variation": "Black",
"contribution_sku": "UBFURNITURERISERSB",
"sku_id": 44678397301802,
"quantity_purchased": 2,
"quantity_shipped": 2,
"quantity_to_ship": 0,
"purchase_date": "Dec 27, 2024, 1:05 am PKT",
"latest_shipping_time": "Dec 29, 2024, 10:30 am PKT",
"latest_delivery_time": "Jan 5, 2025, 9:59 am PKT",
"activity_goods_base_price": 10,
"base_price_total": 13.98,
"tracking_number": 61290359305349930000,
"carrier": "FedEx",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-19958098619433521",
"order_status": "Delivered",
"order_item_id": "211-19958166776873521",
"order_item_status": "Delivered",
"product_name": "Bed Furniture Risers - Set of 8 pcs (4 x 3 Inch & 4 x 5 Inch) Heavy Duty Bed Risers - Supports 1300 Lbs - Can Be Combined To Make 4 x 8 Inch Riser",
"variation": "Black",
"contribution_sku": "UBFURNITURERISERSB",
"sku_id": 44678397301802,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"purchase_date": "Dec 27, 2024, 12:52 am PKT",
"latest_shipping_time": "Dec 29, 2024, 11:30 am PKT",
"latest_delivery_time": "Jan 5, 2025, 9:59 am PKT",
"activity_goods_base_price": 10,
"base_price_total": 13.98,
"tracking_number": 61290359305349930000,
"carrier": "FedEx",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-19997749601833317",
"order_status": "Delivered",
"order_item_id": "211-19997770081833317",
"order_item_status": "Delivered",
"product_name": "Utopia Bedding All-Season Down Alternative Comforter - Light Weight Plush Duvet Insert with Siliconized Fiberfill and Box Stitching",
"variation": "White / King (90 x 102 Inches)",
"contribution_sku": "UBCOMFORTERLIGHTWEIGHTKINGWHITE-UB0059",
"sku_id": 46061376809107,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"purchase_date": "Dec 27, 2024, 1:08 am PKT",
"latest_shipping_time": "Dec 29, 2024, 10:30 am PKT",
"latest_delivery_time": "Jan 5, 2025, 9:59 am PKT",
"base_price_total": 24,
"tracking_number": 61290359305349930000,
"carrier": "FedEx",
"order_settlement_status": "Unsettled"
},
{
"order_id": "PO-211-20333325834791026",
"order_status": "Delivered",
"order_item_id": "211-20333336320551026",
"order_item_status": "Delivered",
"product_name": "NY Threads Women's Flannel Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe",
"variation": "Grey / X-Large",
"contribution_sku": "NYTBATHROBEWOMENHOODDGREYXL",
"sku_id": 49351321720161,
"quantity_purchased": 1,
"quantity_shipped": 1,
"quantity_to_ship": 0,
"purchase_date": "Dec 27, 2024, 1:33 am PKT",
"latest_shipping_time": "Dec 29, 2024, 1:09 pm PKT",
"latest_delivery_time": "Jan 5, 2025, 9:59 am PKT",
"activity_goods_base_price": 12.99,
"base_price_total": 14.99,
"tracking_number": "1ZH934B6YW15917139",
"carrier": "UPS",
"order_settlement_status": "Unsettled"
}
]

File diff suppressed because it is too large Load Diff

274
index.js Normal file
View File

@ -0,0 +1,274 @@
const puppeteer = require("puppeteer");
const axios = require("axios");
const luxon = require("luxon");
const { exit } = require("process");
const fs = require("fs");
const path = require("path");
const dotenv = require("dotenv").config({ path: __dirname + "/.env" });
const utils = require("./utils");
(async function () {
/**
* loading config data
*/
const config = JSON.parse(fs.readFileSync(__dirname + "/config.json"));
const environment = process.env["ENVIRONMENT"];
const cryptoConfig = utils.getCryptoConfig();
const email = utils.decryptString(
process.env["temu-email"],
cryptoConfig.algo,
cryptoConfig.key,
cryptoConfig.iv
);
const password = utils.decryptString(
process.env["temu-password"],
cryptoConfig.algo,
cryptoConfig.key,
cryptoConfig.iv
);
const currentTimestamp = luxon.DateTime.now().toFormat("yyyy-MM-dd");
/*
* load cookies
*/
const loadPageCookies = async function (page) {
const cookiesFileName = `cookies.json`;
if (fs.existsSync(__dirname + `/cookies/${cookiesFileName}`)) {
const cookiesStr = fs.readFileSync(
__dirname + `/cookies/${cookiesFileName}`
);
const cookies = JSON.parse(cookiesStr);
await page.setCookie(...cookies);
}
};
// launch browser and open page
const chromeProfilePath = path.resolve(
__dirname,
config[environment]["chrome_profile_path"]
);
const browser = await puppeteer.launch(
utils.getBrowserConfig(chromeProfilePath, environment)
);
const page = await browser.newPage();
await loadPageCookies(page);
await page.setViewport({
width: 1600,
height: 900,
});
// save cookies on page load
const cookiesFileName = `cookies.json`;
page.on("load", async function () {
// save cookies
const cookies = await page.cookies();
fs.writeFileSync(
__dirname + `/cookies/${cookiesFileName}`,
JSON.stringify(cookies, null, 2)
);
});
/*
* goto login page
*/
const loginPage = config[environment]["temuLoginPage"];
await page.goto(loginPage, {
waitUntil: ["domcontentloaded"],
});
await utils.tryTemuLogin(page, email, password, loginPage);
await new Promise((resolve) => setTimeout(resolve, 7000));
// goto unshipped order page
const ordersPage = config[environment]["temuOrdersPage"];
await page.goto(ordersPage, {
waitUntil: ["domcontentloaded"],
});
// orders array
let orders = [];
const pagination = 10;
let total_items = 0;
let currentPage = 1;
// get total items
await page
.waitForSelector("li.PGT_totalText_123", { timeout: 5000 })
.catch(() => {});
const liText = await page.evaluate(() => {
const liElement = document.querySelector("li.PGT_totalText_123");
return liElement ? liElement.textContent : null;
});
total_items = parseInt(liText.split(" ")[1]);
console.log(`Total Items count : ${total_items}`);
let total_pages = Math.ceil(total_items / pagination);
console.log(`Total Pages count : ${total_pages}`);
// transform data
const transformData = (data) => {
const result = {};
const pageItems = data.result.pageItems;
pageItems.forEach(item => {
const parentOrderSn = item.parentOrderMap.parentOrderSn;
const orderList = item.orderList;
if (!result[parentOrderSn]) {
result[parentOrderSn] = { items: [] };
}
orderList.forEach(order => {
const sku = order.extCodeList[0];
const quantity = order.quantity;
result[parentOrderSn].items.push({ sku, quantity });
});
});
return result;
};
let getPageOrderData = async (page) => {
/**
* capture response
*/
page.on("response", async function (res) {
try {
const req = res.request();
if (req.url().includes("/recentOrderList")) {
const resJson = await res.json();
// add into data
orders.push( transformData( resJson ) );
// if (resJson.hasOwnProperty("result")) {
// if (
// resJson["result"] !== null &&
// resJson["result"]["pageItems"] !== null
// ) {
// let pList = resJson["result"]["pageItems"];
// for (const pMap of pList) {
// console.log(pMap.parentOrderMap.parentOrderSn);
// orders.push(pMap.parentOrderMap.parentOrderSn);
// }
// }
// }
}
} catch (ex) {
console.log(ex);
}
});
};
// crawl next pages
while ( true ) {
console.log(`Crawling for page ${currentPage}`);
await utils.tryTemuLogin(page, email, password, loginPage);
await new Promise((resolve) => setTimeout(resolve, 4000));
// load cookies
await loadPageCookies(page);
// get orders data
await getPageOrderData(page);
// increment page
++currentPage;
// Evaluate the presence of both classes in the <li> element
const hasNextBtn = await page.evaluate(() => {
const liElement = document.querySelector(
"li.PGT_next_123.PGT_disabled_123"
);
return liElement == null;
});
// break if doesn't have next button
if (!hasNextBtn) {
console.log("No next button");
break;
}
if (currentPage > total_pages) {
console.log("Last Page Reached");
break;
}
// goto next page
if (hasNextBtn) {
await page.evaluate(() => {
const liElement = document.querySelector("li.PGT_next_123");
if (liElement) {
liElement.click();
}
});
}
// wait
await new Promise((r) => setTimeout(r, 5000));
}
try {
// fs.writeFileSync(
// `${__dirname}/orders/${currentTimestamp}.json`,
// JSON.stringify(orders, null, 2)
// );
} catch (e) {
console.log(e);
}
/*
* goto order page
*/
const syncOrders = async () => {
console.log(">--- Syncing Orders ----<");
try {
// get all orders of current date
const orders = JSON.parse(
fs.readFileSync(__dirname + `/orders/${currentTimestamp}.json`)
);
const poSet = new Set();
//
for (const order of orders ) {
for( const poKey of Object.keys(order) ) {
if( ! poSet.has( poKey ) ){
poSet.add( poKey )
const po = order[poKey];
// goto every order page
console.log(`Syncing for : ${poKey}`);
const orderUrl = utils.getTemuOrderPage(poKey);
await page.goto(orderUrl, {
waitUntil: ["domcontentloaded"],
});
const buyShippingBtn = "span._2DQ2xCuz";
await page.waitForSelector(buyShippingBtn, { timeout: 1000 }).catch(() => {});
let buyShippingBtnElement = (await page.$(buyShippingBtn)) !== null;
if (buyShippingBtnElement) {
await page.click(buyShippingBtn);
}
}
await new Promise((resolve) => setTimeout(resolve, 45 * 1000));
}
}
} catch (ex) {
console.log(ex);
}
}
await syncOrders();
await page.close();
await browser.close();
})();

2313
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

24
package.json Normal file
View File

@ -0,0 +1,24 @@
{
"name": "temu_sales",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.27.2",
"base32-encode": "^2.0.0",
"dotenv": "^16.0.3",
"express": "^4.18.1",
"luxon": "^3.3.0",
"node-fetch": "^3.3.2",
"otplib": "^12.0.1",
"puppeteer": "^22.8.2",
"thirty-two": "^1.0.2",
"xlsx": "^0.18.5"
}
}

6
pages.json Normal file
View File

@ -0,0 +1,6 @@
{
"PENDING" : 1,
"UNSHIPPING" : 2,
"CANCELLED" : 3,
"SHIPPED" : 4
}

View File

@ -0,0 +1,21 @@
order id,order status,Logistics service suggestion,Order item ID,order item status,product name,variation,contribution sku,sku id,quantity purchased,quantity shipped,quantity to ship,recipient name,recipient first name,recipient last name,recipient phone number,ship address 1,ship address 2,ship address 3,ship region name4,ship city,ship state,ship postal code,ship country ,purchase date,latest shipping time,latest delivery time,iPhone serial number,virtual email,activity goods base price,base price total,tracking number,carrier,order settlement status
PO-211-20082395387433834,Canceled,,211-20082374415913834,Canceled,"Utopia Bedding 100% Waterproof Mattress Encasement Zippered - Bed Bug Proof Mattress Protector - Absorbent, Six-Sided Mattress Cover",Twin (39 x 75 Inches),UBCFKENCASEMENTMATTRESSTWIN10-UB1201,48775796109117 ,2 ,0 ,0 ,,,,,,,,,,,,,"Dec 27, 2024, 12:52 am PKT","Dec 29, 2024, 12:09 pm PKT","Jan 5, 2025, 10:59 am PKT",,,$8.55,$9.50,,,
PO-211-20082395387433834,Canceled,,211-20082366551593834,Canceled,"Utopia Bedding 100% Waterproof Mattress Encasement Zippered - Bed Bug Proof Mattress Protector - Absorbent, Six-Sided Mattress Cover",Full (54 x 75 Inches),UBCFKENCASEMENTMATTRESSFULL10-UB1202,41113574480683 ,3 ,0 ,0 ,,,,,,,,,,,,,"Dec 27, 2024, 12:52 am PKT","Dec 29, 2024, 12:09 pm PKT","Jan 5, 2025, 10:59 am PKT",,,$11.97,$13.30,,,
PO-211-20149696451112123,Shipped,,211-20149691208232123,Shipped,"Utopia Towels 8 Premium Towels, 2 Bath Towels, 2 Hand Towels, and 4 Wash Cloths, Highly Absorbent 600 GSM 100% Ring Spun Cotton Towels for Bathroom, Hotel, Spa, Gym",Plum,UTSLTOWELSETPLUM2,48114371175913 ,1 ,1 ,0 ,Adelia Chambers,Adelia,Chambers,13145302267-0437,217 Avalone Dr,,,,APOPKA,FL,32703-4609,United States,"Dec 27, 2024, 1:16 am PKT","Dec 29, 2024, 10:30 am PKT","Jan 5, 2025, 9:59 am PKT",,2zeua6thus120b9@us.shipping.temuemail.com,$18.50,$24.10,1ZH934B6YW24924551,UPS,Unsettled
PO-211-20106890563112376,Shipped,,211-20106848620072376,Shipped,"NY Threads Men Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe",Navy / Large/X-Large,NYTBATHROBEMENHOODNAVYL/XL,38158636960077 ,1 ,1 ,0 ,Frances Robinson,,,13145570888-7219,9103 Bay Port Cir,,,,INDIANAPOLIS,IN,46236-9343,United States,"Dec 27, 2024, 1:10 am PKT","Dec 29, 2024, 10:30 am PKT","Jan 5, 2025, 9:59 am PKT",,6gnehmo5vm12056@us.shipping.temuemail.com,$15.11,$20.70,61290359305349927385 ,FedEx,Unsettled
PO-211-20524199414310179,Shipped,,211-20524237425190179,Shipped,"NY Threads Women's Flannel Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe",Burgundy / Small,NYTBATHROBEWOMENHOODBURGUNDYS,44480828840124 ,1 ,1 ,0 ,Carole LaRue,,,13145499797-6824,105 Ravenswood Court,,,,PETALUMA,CA,94952 ,United States,"Dec 27, 2024, 1:14 am PKT","Dec 29, 2024, 3:13 pm PKT","Jan 5, 2025, 12:59 pm PKT",,vkob5rju3m1207e@us.shipping.temuemail.com,$12.99,$14.99,61290359305349927361 ,FedEx,Unsettled
PO-211-20055047634473999,Shipped,,211-20055026662953999,Shipped,"Utopia Towels 8 Premium Towels, 2 Bath Towels, 2 Hand Towels, and 4 Wash Cloths, Highly Absorbent 600 GSM 100% Ring Spun Cotton Towels for Bathroom, Hotel, Spa, Gym",Black,UTSLTOWELSETBLACK4,37351183150205 ,1 ,1 ,0 ,Kasper Gautier,Kasper,Gautier,13145301849-0304,1000 Watermark Pl,511 ,,,COLUMBIA,SC,29210-8232,United States,"Dec 27, 2024, 1:24 am PKT","Dec 29, 2024, 10:30 am PKT","Jan 5, 2025, 9:59 am PKT",,ssjjaj3bde120f0@us.shipping.temuemail.com,$18.50,$32.00,61290359305349927378 ,FedEx,Unsettled
PO-211-20162713917992077,Shipped,,211-20162734889512077,Shipped,"NY Threads Men Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe",Navy / 2X-Large/3XLarge,NYTBATHROBEMENHOODNAVY2XL3XL,43415676913835 ,1 ,1 ,0 ,Cheryl Short,,,13145497921-2246,4432 Spring Blossom Dr,,,,KISSIMMEE,FL,34746-2302,United States,"Dec 27, 2024, 12:54 am PKT","Dec 29, 2024, 10:30 am PKT","Jan 5, 2025, 9:59 am PKT",,rf6zikjg2t120e4@us.shipping.temuemail.com,$14.52,$19.90,1ZH934B6YW21059019,UPS,Unsettled
PO-211-20389450243112004,Shipped,,211-20389502671912004,Shipped,Utopia Bedding 4 Piece Bedding Set - Fade & Shrinkage Resistant Brushed Microfiber - Easy Care,Navy / King,UB0260-UBMICROFIBER4PCKINGNAVY,43278237966822 ,1 ,1 ,0 ,Sonia Daly,Sonia,Daly,13145300856-6585,4440 Danny R Wimberly Dr apt 39,39 ,,,SHREVEPORT,LA,71119 ,United States,"Dec 27, 2024, 12:10 am PKT","Dec 29, 2024, 11:30 am PKT","Jan 5, 2025, 10:59 am PKT",,gc73zngziv1205f@us.shipping.temuemail.com,,$13.15,1ZH934B6YW36710189,UPS,Unsettled
PO-211-20533522253350891,Shipped,,211-20533616625190891,Shipped,"NY Threads Women's Flannel Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe",Black / Small,NYTBATHROBEWOMENHOODBLACKS,48346299418388 ,1 ,1 ,0 ,Barbara Tuson,,,13145301849-6211,2619 W Latrobe St,house,,,PEORIA,IL,61605-1451,United States,"Dec 27, 2024, 1:29 am PKT","Dec 29, 2024, 11:30 am PKT","Jan 5, 2025, 10:59 am PKT",,hpokbsbs6w120ae@us.shipping.temuemail.com,$12.99,$14.99,1ZH934B6YW34387024,UPS,Unsettled
PO-211-19990411766313102,Shipped,,211-19990470748713102,Shipped,Bed Furniture Risers - Set of 8 pcs (4 x 3 Inch & 4 x 5 Inch) Heavy Duty Bed Risers - Supports 1300 Lbs - Can Be Combined To Make 4 x 8 Inch Riser,Brown,UBFURNITURERISERBROWN,37471442215596 ,1 ,1 ,0 ,Laura Sanburn,,,13145499781-3411,14607 Highland Rdg,,,,SAN ANTONIO,TX,78233-3855,United States,"Dec 27, 2024, 12:58 am PKT","Dec 29, 2024, 11:30 am PKT","Jan 5, 2025, 10:59 am PKT",,jflmcmgqdi12038@us.shipping.temuemail.com,$10.00,$12.28,1ZH934B6YW17689141,UPS,Unsettled
PO-211-20152340442152139,Shipped,,211-20152324713512139,Shipped,Utopia Bedding All-Season Down Alternative Comforter - Light Weight Plush Duvet Insert with Siliconized Fiberfill and Box Stitching,White / Queen (88 x 88 Inches),UBCOMFORTERLIGHTWEIGHTQUEENWHITE-UB0060,42204496181519 ,1 ,1 ,0 ,Bonnie Harro,,,13145300294-2981,4816 O Ct NE,,,,AUBURN,WA,98002-1229,United States,"Dec 27, 2024, 1:00 am PKT","Dec 29, 2024, 1:30 pm PKT","Jan 5, 2025, 12:59 pm PKT",,wz72i4w23j12084@us.shipping.temuemail.com,$16.38,$18.20,61290359305349930897 ,FedEx,Unsettled
PO-211-20060053786153681,Shipped,,211-20060038057513681,Shipped,"Utopia Bedding 100% Waterproof Mattress Encasement Zippered - Bed Bug Proof Mattress Protector - Absorbent, Six-Sided Mattress Cover",King (78 x 80 Inches),UBCFKENCASEMENTMATTRESSKING-UB0034,52211769976359 ,1 ,1 ,0 ,Letty Mijares,,,13145301816-1088,1929 SE 8th Ter,,,,CAPE CORAL,FL,33990-1636,United States,"Dec 27, 2024, 1:07 am PKT","Dec 29, 2024, 10:30 am PKT","Jan 5, 2025, 9:59 am PKT",,uograjkcxo120c7@us.shipping.temuemail.com,$14.00,$16.70,1ZH934B6YW08608227,UPS,Unsettled
PO-211-20335640893991047,Shipped,,211-20335651379751047,Shipped,Utopia Kitchen 12 & 24 Pack - 28 x 28 Inches Flour Sack Towels 100% Cotton Cleaning & Drying Tea Towels - Highly Absorbent Dish Towels,Beige / 12 Pack,UKFLOURSACK12-BEIGE-UK0534,39842264180714 ,2 ,2 ,0 ,Susan Hisgen,,,13145303633-2427,1003 Hacienda Drive,,,,SUN CITY CENTER,FL,33573 ,United States,"Dec 27, 2024, 12:26 am PKT","Dec 29, 2024, 10:30 am PKT","Jan 5, 2025, 9:59 am PKT",,6hllnq73ft12002@us.shipping.temuemail.com,$10.92,$11.50,1ZH934B6YW39992156,UPS,Unsettled
PO-211-20163906481192068,Shipped,,211-20163890752552068,Shipped,"Utopia Bedding 100% Waterproof Mattress Encasement Zippered - Bed Bug Proof Mattress Protector - Absorbent, Six-Sided Mattress Cover",Queen (60 x 80 Inches),UBCFKENCASEMENTMATTRESSQUEEN10-UB1205,49995566843268 ,1 ,1 ,0 ,Tyler Estep,Tyler,Estep,13145300344-6065,400 Pecan Ln,,,,SOMERVILLE,TX,77879-5564,United States,"Dec 27, 2024, 1:35 am PKT","Dec 29, 2024, 5:13 pm PKT","Jan 5, 2025, 10:59 am PKT",,fvk5pcmc761209f@us.shipping.temuemail.com,$12.00,$13.99,1ZH934B6YW28568135,UPS,Unsettled
PO-211-20543579238950831,Delivered,,211-20543571374630831,Delivered,Bed Furniture Risers - Set of 8 pcs (4 x 3 Inch & 4 x 5 Inch) Heavy Duty Bed Risers - Supports 1300 Lbs - Can Be Combined To Make 4 x 8 Inch Riser,Brown,UBFURNITURERISERBROWN,37471442215596 ,1 ,1 ,0 ,,,,,,,,,,,,,"Dec 27, 2024, 12:37 am PKT","Dec 29, 2024, 10:30 am PKT","Jan 5, 2025, 9:59 am PKT",,,$10.00,$12.28,61290359305349927163 ,FedEx,Unsettled
PO-211-20461558684710262,Delivered,,211-20461540334630262,Delivered,"NY Threads Women's Flannel Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe",Black / Large,NYTBATHROBEWOMENHOODBLACKL,44858785940399 ,1 ,1 ,0 ,,,,,,,,,,,,,"Dec 27, 2024, 1:18 am PKT","Dec 29, 2024, 10:30 am PKT","Jan 5, 2025, 9:59 am PKT",,,$12.99,$14.99,61290359305349935632 ,FedEx,Unsettled
PO-211-20319235215911142,Delivered,,211-20319258808871142,Delivered,Bed Furniture Risers - Set of 8 pcs (4 x 3 Inch & 4 x 5 Inch) Heavy Duty Bed Risers - Supports 1300 Lbs - Can Be Combined To Make 4 x 8 Inch Riser,Black,UBFURNITURERISERSB,44678397301802 ,2 ,2 ,0 ,,,,,,,,,,,,,"Dec 27, 2024, 1:05 am PKT","Dec 29, 2024, 10:30 am PKT","Jan 5, 2025, 9:59 am PKT",,,$10.00,$13.98,61290359305349927354 ,FedEx,Unsettled
PO-211-19958098619433521,Delivered,,211-19958166776873521,Delivered,Bed Furniture Risers - Set of 8 pcs (4 x 3 Inch & 4 x 5 Inch) Heavy Duty Bed Risers - Supports 1300 Lbs - Can Be Combined To Make 4 x 8 Inch Riser,Black,UBFURNITURERISERSB,44678397301802 ,1 ,1 ,0 ,,,,,,,,,,,,,"Dec 27, 2024, 12:52 am PKT","Dec 29, 2024, 11:30 am PKT","Jan 5, 2025, 9:59 am PKT",,,$10.00,$13.98,61290359305349927347 ,FedEx,Unsettled
PO-211-19997749601833317,Delivered,,211-19997770081833317,Delivered,Utopia Bedding All-Season Down Alternative Comforter - Light Weight Plush Duvet Insert with Siliconized Fiberfill and Box Stitching,White / King (90 x 102 Inches),UBCOMFORTERLIGHTWEIGHTKINGWHITE-UB0059,46061376809107 ,1 ,1 ,0 ,,,,,,,,,,,,,"Dec 27, 2024, 1:08 am PKT","Dec 29, 2024, 10:30 am PKT","Jan 5, 2025, 9:59 am PKT",,,,$24.00,61290359305349930828 ,FedEx,Unsettled
PO-211-20333325834791026,Delivered,,211-20333336320551026,Delivered,"NY Threads Women's Flannel Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe",Grey / X-Large,NYTBATHROBEWOMENHOODDGREYXL,49351321720161 ,1 ,1 ,0 ,,,,,,,,,,,,,"Dec 27, 2024, 1:33 am PKT","Dec 29, 2024, 1:09 pm PKT","Jan 5, 2025, 9:59 am PKT",,,$12.99,$14.99,1ZH934B6YW15917139,UPS,Unsettled
1 order id order status Logistics service suggestion Order item ID order item status product name variation contribution sku sku id quantity purchased quantity shipped quantity to ship recipient name recipient first name recipient last name recipient phone number ship address 1 ship address 2 ship address 3 ship region name4 ship city ship state ship postal code ship country purchase date latest shipping time latest delivery time iPhone serial number virtual email activity goods base price base price total tracking number carrier order settlement status
2 PO-211-20082395387433834 Canceled 211-20082374415913834 Canceled Utopia Bedding 100% Waterproof Mattress Encasement Zippered - Bed Bug Proof Mattress Protector - Absorbent, Six-Sided Mattress Cover Twin (39 x 75 Inches) UBCFKENCASEMENTMATTRESSTWIN10-UB1201 48775796109117 2 0 0 Dec 27, 2024, 12:52 am PKT Dec 29, 2024, 12:09 pm PKT Jan 5, 2025, 10:59 am PKT $8.55 $9.50
3 PO-211-20082395387433834 Canceled 211-20082366551593834 Canceled Utopia Bedding 100% Waterproof Mattress Encasement Zippered - Bed Bug Proof Mattress Protector - Absorbent, Six-Sided Mattress Cover Full (54 x 75 Inches) UBCFKENCASEMENTMATTRESSFULL10-UB1202 41113574480683 3 0 0 Dec 27, 2024, 12:52 am PKT Dec 29, 2024, 12:09 pm PKT Jan 5, 2025, 10:59 am PKT $11.97 $13.30
4 PO-211-20149696451112123 Shipped 211-20149691208232123 Shipped Utopia Towels 8 Premium Towels, 2 Bath Towels, 2 Hand Towels, and 4 Wash Cloths, Highly Absorbent 600 GSM 100% Ring Spun Cotton Towels for Bathroom, Hotel, Spa, Gym Plum UTSLTOWELSETPLUM2 48114371175913 1 1 0 Adelia Chambers Adelia Chambers 13145302267-0437 217 Avalone Dr APOPKA FL 32703-4609 United States Dec 27, 2024, 1:16 am PKT Dec 29, 2024, 10:30 am PKT Jan 5, 2025, 9:59 am PKT 2zeua6thus120b9@us.shipping.temuemail.com $18.50 $24.10 1ZH934B6YW24924551 UPS Unsettled
5 PO-211-20106890563112376 Shipped 211-20106848620072376 Shipped NY Threads Men Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe Navy / Large/X-Large NYTBATHROBEMENHOODNAVYL/XL 38158636960077 1 1 0 Frances Robinson 13145570888-7219 9103 Bay Port Cir INDIANAPOLIS IN 46236-9343 United States Dec 27, 2024, 1:10 am PKT Dec 29, 2024, 10:30 am PKT Jan 5, 2025, 9:59 am PKT 6gnehmo5vm12056@us.shipping.temuemail.com $15.11 $20.70 61290359305349927385 FedEx Unsettled
6 PO-211-20524199414310179 Shipped 211-20524237425190179 Shipped NY Threads Women's Flannel Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe Burgundy / Small NYTBATHROBEWOMENHOODBURGUNDYS 44480828840124 1 1 0 Carole LaRue 13145499797-6824 105 Ravenswood Court PETALUMA CA 94952 United States Dec 27, 2024, 1:14 am PKT Dec 29, 2024, 3:13 pm PKT Jan 5, 2025, 12:59 pm PKT vkob5rju3m1207e@us.shipping.temuemail.com $12.99 $14.99 61290359305349927361 FedEx Unsettled
7 PO-211-20055047634473999 Shipped 211-20055026662953999 Shipped Utopia Towels 8 Premium Towels, 2 Bath Towels, 2 Hand Towels, and 4 Wash Cloths, Highly Absorbent 600 GSM 100% Ring Spun Cotton Towels for Bathroom, Hotel, Spa, Gym Black UTSLTOWELSETBLACK4 37351183150205 1 1 0 Kasper Gautier Kasper Gautier 13145301849-0304 1000 Watermark Pl 511 COLUMBIA SC 29210-8232 United States Dec 27, 2024, 1:24 am PKT Dec 29, 2024, 10:30 am PKT Jan 5, 2025, 9:59 am PKT ssjjaj3bde120f0@us.shipping.temuemail.com $18.50 $32.00 61290359305349927378 FedEx Unsettled
8 PO-211-20162713917992077 Shipped 211-20162734889512077 Shipped NY Threads Men Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe Navy / 2X-Large/3XLarge NYTBATHROBEMENHOODNAVY2XL3XL 43415676913835 1 1 0 Cheryl Short 13145497921-2246 4432 Spring Blossom Dr KISSIMMEE FL 34746-2302 United States Dec 27, 2024, 12:54 am PKT Dec 29, 2024, 10:30 am PKT Jan 5, 2025, 9:59 am PKT rf6zikjg2t120e4@us.shipping.temuemail.com $14.52 $19.90 1ZH934B6YW21059019 UPS Unsettled
9 PO-211-20389450243112004 Shipped 211-20389502671912004 Shipped Utopia Bedding 4 Piece Bedding Set - Fade & Shrinkage Resistant Brushed Microfiber - Easy Care Navy / King UB0260-UBMICROFIBER4PCKINGNAVY 43278237966822 1 1 0 Sonia Daly Sonia Daly 13145300856-6585 4440 Danny R Wimberly Dr apt 39 39 SHREVEPORT LA 71119 United States Dec 27, 2024, 12:10 am PKT Dec 29, 2024, 11:30 am PKT Jan 5, 2025, 10:59 am PKT gc73zngziv1205f@us.shipping.temuemail.com $13.15 1ZH934B6YW36710189 UPS Unsettled
10 PO-211-20533522253350891 Shipped 211-20533616625190891 Shipped NY Threads Women's Flannel Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe Black / Small NYTBATHROBEWOMENHOODBLACKS 48346299418388 1 1 0 Barbara Tuson 13145301849-6211 2619 W Latrobe St house PEORIA IL 61605-1451 United States Dec 27, 2024, 1:29 am PKT Dec 29, 2024, 11:30 am PKT Jan 5, 2025, 10:59 am PKT hpokbsbs6w120ae@us.shipping.temuemail.com $12.99 $14.99 1ZH934B6YW34387024 UPS Unsettled
11 PO-211-19990411766313102 Shipped 211-19990470748713102 Shipped Bed Furniture Risers - Set of 8 pcs (4 x 3 Inch & 4 x 5 Inch) Heavy Duty Bed Risers - Supports 1300 Lbs - Can Be Combined To Make 4 x 8 Inch Riser Brown UBFURNITURERISERBROWN 37471442215596 1 1 0 Laura Sanburn 13145499781-3411 14607 Highland Rdg SAN ANTONIO TX 78233-3855 United States Dec 27, 2024, 12:58 am PKT Dec 29, 2024, 11:30 am PKT Jan 5, 2025, 10:59 am PKT jflmcmgqdi12038@us.shipping.temuemail.com $10.00 $12.28 1ZH934B6YW17689141 UPS Unsettled
12 PO-211-20152340442152139 Shipped 211-20152324713512139 Shipped Utopia Bedding All-Season Down Alternative Comforter - Light Weight Plush Duvet Insert with Siliconized Fiberfill and Box Stitching White / Queen (88 x 88 Inches) UBCOMFORTERLIGHTWEIGHTQUEENWHITE-UB0060 42204496181519 1 1 0 Bonnie Harro 13145300294-2981 4816 O Ct NE AUBURN WA 98002-1229 United States Dec 27, 2024, 1:00 am PKT Dec 29, 2024, 1:30 pm PKT Jan 5, 2025, 12:59 pm PKT wz72i4w23j12084@us.shipping.temuemail.com $16.38 $18.20 61290359305349930897 FedEx Unsettled
13 PO-211-20060053786153681 Shipped 211-20060038057513681 Shipped Utopia Bedding 100% Waterproof Mattress Encasement Zippered - Bed Bug Proof Mattress Protector - Absorbent, Six-Sided Mattress Cover King (78 x 80 Inches) UBCFKENCASEMENTMATTRESSKING-UB0034 52211769976359 1 1 0 Letty Mijares 13145301816-1088 1929 SE 8th Ter CAPE CORAL FL 33990-1636 United States Dec 27, 2024, 1:07 am PKT Dec 29, 2024, 10:30 am PKT Jan 5, 2025, 9:59 am PKT uograjkcxo120c7@us.shipping.temuemail.com $14.00 $16.70 1ZH934B6YW08608227 UPS Unsettled
14 PO-211-20335640893991047 Shipped 211-20335651379751047 Shipped Utopia Kitchen 12 & 24 Pack - 28 x 28 Inches Flour Sack Towels 100% Cotton Cleaning & Drying Tea Towels - Highly Absorbent Dish Towels Beige / 12 Pack UKFLOURSACK12-BEIGE-UK0534 39842264180714 2 2 0 Susan Hisgen 13145303633-2427 1003 Hacienda Drive SUN CITY CENTER FL 33573 United States Dec 27, 2024, 12:26 am PKT Dec 29, 2024, 10:30 am PKT Jan 5, 2025, 9:59 am PKT 6hllnq73ft12002@us.shipping.temuemail.com $10.92 $11.50 1ZH934B6YW39992156 UPS Unsettled
15 PO-211-20163906481192068 Shipped 211-20163890752552068 Shipped Utopia Bedding 100% Waterproof Mattress Encasement Zippered - Bed Bug Proof Mattress Protector - Absorbent, Six-Sided Mattress Cover Queen (60 x 80 Inches) UBCFKENCASEMENTMATTRESSQUEEN10-UB1205 49995566843268 1 1 0 Tyler Estep Tyler Estep 13145300344-6065 400 Pecan Ln SOMERVILLE TX 77879-5564 United States Dec 27, 2024, 1:35 am PKT Dec 29, 2024, 5:13 pm PKT Jan 5, 2025, 10:59 am PKT fvk5pcmc761209f@us.shipping.temuemail.com $12.00 $13.99 1ZH934B6YW28568135 UPS Unsettled
16 PO-211-20543579238950831 Delivered 211-20543571374630831 Delivered Bed Furniture Risers - Set of 8 pcs (4 x 3 Inch & 4 x 5 Inch) Heavy Duty Bed Risers - Supports 1300 Lbs - Can Be Combined To Make 4 x 8 Inch Riser Brown UBFURNITURERISERBROWN 37471442215596 1 1 0 Dec 27, 2024, 12:37 am PKT Dec 29, 2024, 10:30 am PKT Jan 5, 2025, 9:59 am PKT $10.00 $12.28 61290359305349927163 FedEx Unsettled
17 PO-211-20461558684710262 Delivered 211-20461540334630262 Delivered NY Threads Women's Flannel Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe Black / Large NYTBATHROBEWOMENHOODBLACKL 44858785940399 1 1 0 Dec 27, 2024, 1:18 am PKT Dec 29, 2024, 10:30 am PKT Jan 5, 2025, 9:59 am PKT $12.99 $14.99 61290359305349935632 FedEx Unsettled
18 PO-211-20319235215911142 Delivered 211-20319258808871142 Delivered Bed Furniture Risers - Set of 8 pcs (4 x 3 Inch & 4 x 5 Inch) Heavy Duty Bed Risers - Supports 1300 Lbs - Can Be Combined To Make 4 x 8 Inch Riser Black UBFURNITURERISERSB 44678397301802 2 2 0 Dec 27, 2024, 1:05 am PKT Dec 29, 2024, 10:30 am PKT Jan 5, 2025, 9:59 am PKT $10.00 $13.98 61290359305349927354 FedEx Unsettled
19 PO-211-19958098619433521 Delivered 211-19958166776873521 Delivered Bed Furniture Risers - Set of 8 pcs (4 x 3 Inch & 4 x 5 Inch) Heavy Duty Bed Risers - Supports 1300 Lbs - Can Be Combined To Make 4 x 8 Inch Riser Black UBFURNITURERISERSB 44678397301802 1 1 0 Dec 27, 2024, 12:52 am PKT Dec 29, 2024, 11:30 am PKT Jan 5, 2025, 9:59 am PKT $10.00 $13.98 61290359305349927347 FedEx Unsettled
20 PO-211-19997749601833317 Delivered 211-19997770081833317 Delivered Utopia Bedding All-Season Down Alternative Comforter - Light Weight Plush Duvet Insert with Siliconized Fiberfill and Box Stitching White / King (90 x 102 Inches) UBCOMFORTERLIGHTWEIGHTKINGWHITE-UB0059 46061376809107 1 1 0 Dec 27, 2024, 1:08 am PKT Dec 29, 2024, 10:30 am PKT Jan 5, 2025, 9:59 am PKT $24.00 61290359305349930828 FedEx Unsettled
21 PO-211-20333325834791026 Delivered 211-20333336320551026 Delivered NY Threads Women's Flannel Fleece Hooded Bathrobe Long Sleeve For Home Wear, Plush Long Lace Up Spa Robe Grey / X-Large NYTBATHROBEWOMENHOODDGREYXL 49351321720161 1 1 0 Dec 27, 2024, 1:33 am PKT Dec 29, 2024, 1:09 pm PKT Jan 5, 2025, 9:59 am PKT $12.99 $14.99 1ZH934B6YW15917139 UPS Unsettled

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

58
send-orders.js Normal file
View File

@ -0,0 +1,58 @@
const axios = require("axios");
const fs = require("fs");
const path = require("path");
const dotenv = require("dotenv").config({ path: __dirname + "/.env" });
const { exit } = require("process");
(async function () {
/**
* load config data
*/
const config = JSON.parse(fs.readFileSync(__dirname + "/config.json"));
const environment = process.env["ENVIRONMENT"];
/**
* directory path
*/
let ordersPath = config[environment].temu_orders_path;
let unProcessedPath = ordersPath + "/data/unprocessed";
let processedPath = ordersPath + "/data/processed";
if (!fs.existsSync(processedPath)) {
fs.mkdirSync(processedPath);
}
/**
* read all files in directory, send data to cosmos then move to processed
*/
const jsonFiles = fs
.readdirSync(unProcessedPath)
.filter((file) => path.extname(file).toLocaleLowerCase() === ".json");
if( jsonFiles.length === 0 ){
console.log( `No Files Present at ${unProcessedPath}`)
}
for (const file of jsonFiles) {
try {
const filePath = path.join(unProcessedPath, file);
const orders = JSON.parse(fs.readFileSync(filePath, "utf-8"));
console.log(`Processing: ${filePath}`);
// send post request to cosmos
const axiosConfig = {
method: "get",
url: config[environment].cosmos_temu_orders,
headers: {
"Content-Type": "application/json",
},
data: orders, // Add the orders object to the data field
};
const res = await axios(axiosConfig);
if (res["status"] == 200) {
fs.renameSync(filePath, path.join(processedPath, file));
}
} catch (e) {
console.log(e);
}
}
})();

238
sync-orders.js Normal file
View File

@ -0,0 +1,238 @@
const puppeteer = require("puppeteer");
const axios = require("axios");
const luxon = require("luxon");
const { exit } = require("process");
const fs = require("fs");
const path = require("path");
const xlsx = require("xlsx");
const dotenv = require("dotenv").config({ path: __dirname + "/.env" });
const utils = require("./utils");
(async function () {
console.log(`===========< STARTED ${luxon.DateTime.now()} >=========`);
/**
* loading config data
*/
const config = JSON.parse(fs.readFileSync(__dirname + "/config.json"));
const environment = process.env["ENVIRONMENT"];
const cryptoConfig = utils.getCryptoConfig();
const email = utils.decryptString(
process.env["temu-email"],
cryptoConfig.algo,
cryptoConfig.key,
cryptoConfig.iv
);
const password = utils.decryptString(
process.env["temu-password"],
cryptoConfig.algo,
cryptoConfig.key,
cryptoConfig.iv
);
/*
* load cookies
*/
const loadPageCookies = async function (page) {
const cookiesFileName = `cookies.json`;
if (fs.existsSync(__dirname + `/cookies/${cookiesFileName}`)) {
const cookiesStr = fs.readFileSync(
__dirname + `/cookies/${cookiesFileName}`
);
const cookies = JSON.parse(cookiesStr);
await page.setCookie(...cookies);
}
};
// launch browser and open page
const chromeProfilePath = path.resolve(
__dirname,
config[environment]["chrome_profile_path"]
);
const browser = await puppeteer.launch(
utils.getBrowserConfig(chromeProfilePath, environment)
);
const page = await browser.newPage();
await loadPageCookies(page);
await page.setViewport({
width: 1600,
height: 900,
});
// Inject CSS to show the cursor
await page.evaluate(() => {
const style = document.createElement("style");
style.innerHTML = "* { cursor: auto !important; }";
document.head.appendChild(style);
});
// save cookies on page load
const cookiesFileName = `cookies.json`;
page.on("load", async function () {
// save cookies
const cookies = await page.cookies();
fs.writeFileSync(
__dirname + `/cookies/${cookiesFileName}`,
JSON.stringify(cookies, null, 2)
);
});
/*
* configure download path of excel report
*/
const generateTheDownloadPath = async function (page, downloadPath) {
// create client session for configuration
const client = await page.target().createCDPSession();
// set the download path
await client.send("Page.setDownloadBehavior", {
behavior: "allow",
downloadPath: downloadPath, // Change this to your desired download path.
});
};
/*
* goto login page
*/
const loginPage = config[environment]["temuLoginPage"];
await page.goto(loginPage, {
waitUntil: ["domcontentloaded"],
});
await utils.tryTemuLogin(page, email, password, loginPage);
await new Promise((resolve) => setTimeout(resolve, 7000));
// goto orders request page
const ordersRequestPage = config[environment]["temuOrderReportPage"];
await page.goto(ordersRequestPage, {
waitUntil: ["domcontentloaded"],
});
/*
* request order report
*/
const orderRequestSelector = "div._3yOxLjm0._2pgGmJ7w.IoqjAtdZ.vbGE0cGC";
const element = await page.$(orderRequestSelector);
if (element) {
await element.click();
console.log("Clicked on the Request Report btn");
// wait 10 secs
await new Promise((resolve) => setTimeout(resolve, 10 * 1000));
const confirmBtnSelector = "div._3yOxLjm0._2pgGmJ7w._1eT_m6dA";
const confirmBtnElement = await page.$(confirmBtnSelector);
if (confirmBtnElement) {
await new Promise((resolve) => setTimeout(resolve, 15 * 1000));
await confirmBtnElement.click();
console.log("Clicked on the Confirm Button");
// wait for 3 seconds then reload page
await new Promise((resolve) => setTimeout(resolve, 3 * 1000));
// Reload the page
await page.reload();
console.log("Page reloading");
// wait for 3 mins for request to be processed
await new Promise((resolve) => setTimeout(resolve, 3 * 60 * 1000));
}
} else {
console.log(" Request Btn doest exists");
}
// download latest report
await page.waitForSelector("div._2zs6hel0");
// Select all divs with the class _2zs6hel0
const divs = await page.$$("div._2zs6hel0");
console.log(`Found ${divs.length} Buttons`);
const downloadFolderPath = path.resolve(
config[environment].temu_orders_path,
`unprocessed/`
);
// download the latest report
if (divs !== undefined && divs.length > 1) {
generateTheDownloadPath(page, downloadFolderPath);
console.log("Clicking On download Button");
await new Promise((resolve) => setTimeout(resolve, 10 * 1000));
await divs[0].click();
}
// wait 60 seconds
await new Promise((resolve) => setTimeout(resolve, 60 * 1000));
// generate json from excel mark it processed
const unprocessedFolderPath = path.join(
config[environment].temu_orders_path,
"unprocessed"
);
// Function to read Excel files and convert to JSON
const convertExcelToJson = () => {
fs.readdir(unprocessedFolderPath, (err, files) => {
if (err) {
console.error("Error reading the directory:", err);
return;
}
// Filter Excel files (xlsx or xls)
const excelFiles = files.filter(
(file) =>
file.endsWith(".xlsx") ||
file.endsWith(".xls") ||
file.endsWith(".csv")
);
// Process each Excel file
excelFiles.forEach((file) => {
const filePath = path.join(unprocessedFolderPath, file);
const workbook = xlsx.readFile(filePath);
const sheetName = workbook.SheetNames[0]; // Use the first sheet
const worksheet = workbook.Sheets[sheetName];
// Convert the sheet to JSON
let jsonData = xlsx.utils.sheet_to_json(worksheet);
// Modify the column names by adding underscores
jsonData = jsonData.map((row) => {
const modifiedRow = {};
Object.keys(row).forEach((key) => {
const newKey = key.replace(/\s+/g, "_").toLowerCase();
const value =
row[key] === undefined || row[key] === "" || row[key] === null
? ""
: row[key];
modifiedRow[newKey] = value;
});
return modifiedRow;
});
// write the JSON data to a file
const outputFile = path.join(
config[environment].temu_orders_path,
"data/unprocessed",
`${luxon.DateTime.now().toMillis()}.json`
);
fs.writeFileSync(outputFile, JSON.stringify(jsonData, null, 2));
console.log(`Saved JSON to ${outputFile}`);
console.log(
`Move Excel file ${filePath} to ${config[environment].temu_orders_path}/processed`
);
fs.renameSync(
filePath,
path.join(`${config[environment].temu_orders_path}/processed`, file)
);
});
});
};
convertExcelToJson();
console.log(`==========< ENDED ${luxon.DateTime.now()} >==========`);
await page.close();
await browser.close();
})();

288
utils.js Normal file
View File

@ -0,0 +1,288 @@
const crypto = require("crypto");
const { authenticator } = require("otplib");
const dotenv = require("dotenv").config({ path: __dirname + "/.env" });
/**
* get crypto config
*/
const getCryptoConfig = function () {
const ivStr = "1851aa2e5f98522bbe1b8ac1f8305d8a";
return {
key: "tD0!wR6^cH8!mO0)wJ7;bZ0&eW6;iT6>",
iv: Buffer.from(ivStr, "hex"),
algo: "aes-256-cbc",
};
};
exports.getCryptoConfig = getCryptoConfig;
/**
* encrypt string
*/
const encryptString = function (str, algo, key, iv) {
// create cipher
const cipher = crypto.createCipheriv(algo, Buffer.from(key), iv);
// encrypt data
let encryptedStr = cipher.update(str);
encryptedStr = Buffer.concat([encryptedStr, cipher.final()]);
return encryptedStr.toString("hex");
};
exports.encryptString = encryptString;
/**
* decrypt string
*/
const decryptString = function (encryptedStr, algo, key, iv) {
// create decipher
const decipher = crypto.createDecipheriv(algo, Buffer.from(key), iv);
// decrypt string
let decryptedStr = decipher.update(Buffer.from(encryptedStr, "hex"));
decryptedStr = Buffer.concat([decryptedStr, decipher.final()]);
return decryptedStr.toString();
};
exports.decryptString = decryptString;
/**
* get browser config
*/
const getBrowserConfig = function (profilePath, env) {
let browserConfig = {};
browserConfig["ignoreDefaultArgs"] = ["--disable-extensions"];
browserConfig["headless"] = true;
// prod specific
if (env === "prod") {
browserConfig["args"] = [
"--disable-gpu",
"--disable-setuid-sandbox",
"--no-sandbox",
"--no-zygote",
`--user-data-dir=${profilePath}`,
];
browserConfig["executablePath"] = "/usr/bin/chromium-browser";
}
// dev specific
if (env === "dev") {
browserConfig["headless"] = false;
browserConfig["args"] = [`--user-data-dir=${profilePath}`];
}
return browserConfig;
};
exports.getBrowserConfig = getBrowserConfig;
/**
* try temu login
*/
const tryTemuLogin = async function (page, username, password) {
try {
// if login required
if( ! page.url().includes('seller.temu.com/login.html') ){
console.log( 'No Login Required' );
return;
}
// click on Sign in link
const selector = "div._31ia9mDL._3n05KUVj._1fE9CAB_";
await page.waitForSelector(selector, { timeout: 5000 }).catch(() => {});
const elementExists = (await page.$(selector)) !== null;
if (elementExists) {
await page.click(selector);
}
// email input
const inputSelectors = "input._3s66f8p-";
await page.waitForSelector(inputSelectors, { timeout: 5000 }).catch((e) => {
console.log(e)
});
const elements = await page.$$(inputSelectors);
console.log( elements )
for (let element of elements) {
const type = await page.evaluate((el) => el.type, element);
if ( type === "password" ) {
await element.type(password);
} else {
await element.type(username);
}
}
const loginBtn = "span._1YdMCUKt"
await page.waitForSelector(loginBtn, { timeout: 5000 }).catch(() => {});
let loginBtnElement = (await page.$(loginBtn)) !== null;
if (loginBtnElement) {
await page.click(loginBtn);
}
} catch (e) {
console.log(e);
}
};
exports.tryTemuLogin = tryTemuLogin;
/**
* try login
*/
const tryLogin = async function (page, username, password, finalUrl, secret) {
try {
// see if email is required to login
const requireEmail = await page.evaluate(async function () {
return document.querySelector("#ap_email") !== null;
});
if (requireEmail) {
console.log("Login: Email is required");
await page.evaluate(async function () {
document.querySelector("#ap_email").value = "";
});
await page.type("#ap_email", username);
}
// see if continue button is required
const continueBtn = await page.evaluate(async function () {
return document.querySelector("#continue") !== null;
});
if (continueBtn) {
console.log("Login: Continue button is required");
await page.click("#continue");
// wait 5s to page to load
await new Promise((resolve) => setTimeout(resolve, 5000));
}
// see if password is required to login
const requirePassword = await page.evaluate(async function () {
return document.querySelector("#ap_password") !== null;
});
if (requirePassword) {
await page.evaluate(async function () {
document.querySelector("#ap_password").value = "";
});
await page.type("#ap_password", password);
}
// check if it has remember me button
const rememberMeBtn = await page.evaluate(async function () {
return document.querySelector('[name="rememberMe"]') !== null;
});
if (rememberMeBtn) {
await page.click('[name="rememberMe"]');
}
// check if we need to click on sign-in button
const requireSubmit = await page.evaluate(async function () {
return document.querySelector("#signInSubmit") !== null;
});
if (requireSubmit) {
console.log("Login: Submit button is required");
await Promise.all([
page.click("#signInSubmit"),
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);
}
// check if device option is required
const requireDeviceOption = await page.evaluate(async function () {
return document.querySelector("#auth-select-device-form") !== null;
});
if (requireDeviceOption) {
// select device option
console.log("Login: Device option is required");
await page.click('.a-radio.auth-TOTP [type="radio"]');
}
// check if send code option is required
const requireSendCode = await page.evaluate(async function () {
return document.querySelector("#auth-send-code") !== null;
});
if (requireSendCode) {
await Promise.all([
page.click("#auth-send-code"),
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);
}
// check if mfa is required
const requireMfa = await page.evaluate(async function () {
return document.querySelector("#auth-mfa-otpcode") !== null;
});
if (requireMfa) {
console.log("Login: MFA is required");
// wait 30s to manually enter mfa
const toptCode = generateotpzfromHash(process.env["totp"]);
await page.type("#auth-mfa-otpcode", toptCode);
await page.click("#auth-signin-button"),
await new Promise((resolve) => setTimeout(resolve, 45 * 1000));
}
// see if we have skip phone number button
const requireSkipPhone = await page.evaluate(async function () {
return (
document.querySelector("#ap-account-fixup-phone-skip-link") !== null
);
});
if (requireSkipPhone) {
await Promise.all([
page.click("#ap-account-fixup-phone-skip-link"),
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);
}
// goto final url
if (
requireEmail ||
requirePassword ||
requireSubmit ||
requireSkipPhone ||
rememberMeBtn
) {
await page.goto(finalUrl, {
waitUntil: ["domcontentloaded"],
});
}
} catch (e) {
console.log(e);
}
};
exports.tryLogin = tryLogin;
/**
* generate code
*/
const generateotpzfromHash = function (secret) {
return authenticator.generate(secret);
};
/**
* get sellercentral home url
*/
const getSellerCentralHomeUrl = function (marketplace) {
const marketplaceObj = marketplaces["marketplaces"][marketplace];
return `https://sellercentral.${marketplaceObj["url"]}/home?mons_sel_dir_mcid=${marketplaceObj["monsSelDirMcid"]}&mons_sel_mkid=${marketplaceObj["marketplaceId"]}&mons_sel_dir_paid=${marketplaceObj["monsSelDirPaid"]}&ignore_selection_changed=true`;
};
exports.getSellerCentralHomeUrl = getSellerCentralHomeUrl;
/**
* get sellercentral inventory url
*/
const getSellerCentralInventoryUrl = function (marketplace) {
const marketplaceObj = marketplaces["marketplaces"][marketplace];
return `https://sellercentral.${marketplaceObj["url"]}/myinventory/inventory?fulfilledBy=all&page=1&pageSize=25&sort=date_created_desc&status=all`;
};
exports.getSellerCentralInventoryUrl = getSellerCentralInventoryUrl;
/*
* temu image url
*/
const getLabelImageUrl = function (imageUrl) {
return `https://aimg.kwcdn.com/upload_aimg/temu/${imageUrl}`;
};
exports.getLabelImageUrl = getLabelImageUrl;
/*
* temu order page
*/
const getTemuOrderPage = function( poNumber ){
return `https://seller.temu.com/order-detail.html?parent_order_sn=${poNumber}`
}
exports.getTemuOrderPage = getTemuOrderPage;
/*
* temu orders page
*/
const getTemuOrdersPage = function( pageNumber ){
return `https://seller.temu.com/orders.html?activeTab=${pageNumber}`;
}
exports.getTemuOrdersPage = getTemuOrdersPage;