Scraping APIFeaturesScrape Shopee

Shopee Website Data Scraping

Parameter Explanation

ParameterTypeValueDescription
actorstringscraper.shopeeFixed entry
input.actionstringshopee.productSupports three types
  1. shopee.product Get product detail data
  2. shopee.search Keyword search data
  3. shopee.live Live related data | | input.url | string | URL link | Supports four types of URL links
  4. The URL link of the product detail page
  5. The API link of the product detail page (/api/v4/pdp/get_pc)
  6. The API link for product search (/api/v4/search/search_items)
  7. The API link for live broadcasts (/api/v1/session/{sessionId}/more_items) |

Product Detail Data

import requests
import json
 
API_KEY = ""
host = "api.scrapeless.com"
url = f"https://{host}/api/v1/scraper/request"
 
payload = json.dumps({
   "actor": "scraper.shopee",
   "input": {
      "action": "shopee.product",
      "url": "https://shopee.tw/2312312.10228173.24803858474"
   }
})
headers = {
   'Content-Type': 'application/json',
   'x-api-token': f'{API_KEY}'
}
 
response = requests.request("POST", url, headers=headers, data=payload)
 
print(response.text)
 

Product Search Data

import requests
import json
 
API_KEY = ""
host = "api.scrapeless.com"
url = f"https://{host}/api/v1/scraper/request"
 
payload = json.dumps({
   "actor": "scraper.shopee",
   "input": {
      "action": "shopee.search",
      "url": "https://shopee.co.th/api/v4/search/search_items?by=sales&keyword=baby%20pants&limit=30&newest=0&order=desc&page_type=search"
   }
})
headers = {
   'Content-Type': 'application/json',
   'x-api-token': f'{API_KEY}'
}
 
response = requests.request("POST", url, headers=headers, data=payload)
 
print(response.text)
 

Live Data

import requests
import json
 
API_KEY = ""
session_id = ""
host = "api.scrapeless.com"
url = f"https://{host}/api/v1/scraper/request"
 
payload = json.dumps({
   "actor": "scraper.shopee",
   "input": {
      "action": "shopee.live",
      "url": f"https://live.shopee.co.th/api/v1/session/{session_id}/more_items?offset=0&limit=10"
   }
})
headers = {
   'Content-Type': 'application/json',
   'x-api-token': f'{API_KEY}'
}
 
response = requests.request("POST", url, headers=headers, data=payload)
 
print(response.text)
 

Product Detail Page API

# The API can be divided into three parts
# 1. region
# 2. item_id
# 3. shop_id
 
# Supported region list
# ["shopee.co.id", "shopee.vn", "shopee.co.th", "shopee.ph", "shopee.com.my", "shopee.sg", "shopee.com.co", "shopee.cl", "shopee.com.mx", "shopee.com.br", "shopee.tw"]
 
url = f"https://{region}/api/v4/pdp/get_pc?item_id={item_id}&shop_id={shop_id}"
print(url)

Product Search API

limit = 20  # 10 20 30 40
order = "desc"
page_type = "search"
keyword = "keyword"   # edit it 
region = "shopee.co.id"
 
# Supported region list
# ["shopee.co.id", "shopee.vn", "shopee.co.th", "shopee.ph", "shopee.com.my", "shopee.sg", "shopee.com.co", "shopee.cl", "shopee.com.mx", "shopee.com.br", "shopee.tw"] 
 
url = f"https://{region}/api/v4/search/search_items?limit={limit}&newest=0&by=sales&keyword={keyword}&order={order}&page_type={page_type}&scenario=PAGE_OTHERS&version=2"
print(url)

Retrieve Task Results via TaskId

import requests
 
API_KEY = ""
host = "api.scrapeless.com"
task_id = ""
 
url = f"https://{host}/api/v1/scraper/result/{task_id}"
 
headers = {
   'x-api-token': f'{API_KEY}'
}
 
response = requests.request("GET", url, headers=headers)
 
print(response.text)