Skip to content

Commit

Permalink
shopee restructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
akherlan committed Mar 15, 2023
1 parent fcef425 commit 486ea26
Show file tree
Hide file tree
Showing 5 changed files with 390 additions and 401 deletions.
48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,56 @@

## Shopee ID

**Racun Shopee** ("Shopee Poison" in Bahasa Indonesia) is a micro influencing and affiliate marketing campaign in Indonesia especially for fashion and beauty products. Usually attract people with showing off OOTD (outfit of the day) looks or make-up preparation and review, then spill and recommend related worth-to-buy products to influence the audiences to purchase on social media.
**Racun Shopee** ("Shopee Poison") is a micro influencing and affiliate marketing campaign in Indonesia especially for fashion and beauty products. Usually attract people with showing off OOTD (outfit of the day) looks or make-up preparation and review, then spill and recommend related worth-to-buy products to influence the audiences to purchase on social media.

This repository is contain codes related to micro and lightweight data collecting through Shopee's public API v4 in idea to achieve automation effort as part of my personal affiliate marketing activity.

Another sale data retrieval tool is written on Google Apps Script and available on Google Sheets as a sticking additional menu (hope can be an add-ons in the future). It can be helpful to supply data for manual spreadsheet analytic purposes.

## Usage

Clone this repository and direct to the project working directory.

The project is using Axios module in Node.js. To running the code you need to install Node.js on your local machine and install required dependencies from `package.json` using npm (Node.js package manager):

```bash
npm install
```

Accessing `flash_catid` (flash sale category id) which useful for filtering flash sale products by their category.

```js
import { get_flash_catid } from './shopee.js';

var catids = await get_flash_catid().then(({ data }) => { return data });
console.log(catids);
```

You will use the category id on the following function:

```js
import { get_flashsale } from './shopee.js';

var products = await get_flashsale(41); // computers and accessories
products.forEach((item, i) => { console.log('%s: %s', i+1, item.name); });
```

When product URL is ready, accessing to the product detail is as follows:

```js
import { get_shopee_product_detail } from './shopee.js'

var url = 'https://shopee.co.id/product/5696604/15949131744';
var product_detail = await get_shopee_product_detail(url);
console.log(product_detail);
```

You can also using product URL from the browser url bar like:

```
https://shopee.co.id/Audio-Technica-ATH-M20xBT-Wireless-Over-Ear-Headphones-i.5696604.15949131744
```

### Caution

Often, the stocks of each tier variation (color, size, type, etc.) do not match at all with the display on the web page. But 0 stock (out of stock) always remains the same. The sold item countings also are not accurate or maybe it has a multiplier factor, etc. Don't know what is it. After all, we may only need information as to whether the item is in stock or out of stock.
Expand Down Expand Up @@ -68,7 +112,7 @@ Please note that Shopee is providing [open API access](https://open.shopee.com/)
## Support
Contributions to this project are welcome. Please open an issue or make a pull request. By submitting a pull request means you agree to [license your contribution](LICENSE.txt) under the MIT license to this project.
Contributions to this project are welcome. Please open an issue or make a pull request. By submitting a pull request means you agree to [license your contribution](LICENSE) under the MIT license to this project.
You can also email me for suggestions.
Expand Down
50 changes: 4 additions & 46 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,5 @@
import { Shopee } from "./shopee.js";
import { ShopeeFlashSale } from "./shopee_flashsale.js";
import { getShopeeProductDetail } from "./shopee_product.js"
import { Zalora } from "./zalora.js";
// import * as fs from 'fs';
import * as shopee from './shopee.js';

/**
* Shopee fashion muslim
*
*/
const getShopeeFlashSaleFashionMuslim = async() => {
// look into flash sale promotion list
const promotionData = await ShopeeFlashSale.getPromotion();
const session = 0; // 0 is current flash sale session
const activePromo = await promotionData[session];
console.info("Retrieve data %s", activePromo.name);
const itemList = await ShopeeFlashSale.getItem(activePromo.url, 34);
// 34 is fashion muslim category, look at ShopeeFlashSale.getCategory(0) for more
const productList = await ShopeeFlashSale.getFlashSale(activePromo.promotionid, itemList);
console.info("Item count: %s", productList.length);
return productList;
}
var fashionMuslim = await getShopeeFlashSaleFashionMuslim();
console.log(fashionMuslim);
// console.log(await Shopee.getCategory());

/**
* Product detail
*
*/
var url = "https://shopee.co.id/GFS-3412-CELANA-KULOT-CRINCLE-PREMIUM-ANTI-KUSUT-2-i.5825746.22420129082?sp_atk=6e0215e0-ea30-4373-9cc6-19c6a799abdb&xptdk=6e0215e0-ea30-4373-9cc6-19c6a799abdb";
var productDetail = await getShopeeProductDetail(url);
console.log(productDetail);


/**
* Zalora
*
*/
var url = "https://www.zalora.co.id/women/pakaian/rok/"
var data = await Zalora.getProduct(url, 1);
if (!data.error) {
data.forEach((item, i) => { console.log("%s: %s <%s>", i+1, item.name, item.link); });
// console.log(data[0]);
} else {
console.log(data);
};
var url = 'https://shopee.co.id/Audio-Technica-ATH-M20xBT-Wireless-Over-Ear-Headphones-i.5696604.15949131744';
var product_detail = await shopee.get_shopee_product_detail(url);
console.log(product_detail);
Loading

0 comments on commit 486ea26

Please sign in to comment.