Scraping APIRecursosRaspe Shopee

Extração de Dados do Site Shopee

Explicação dos Parâmetros

ParâmetroTipoValorDescrição
actorstringscraper.shopeeEntrada fixa
input.actionstringshopee.productSuporta três tipos
  1. shopee.product Obter dados detalhados do produto
  2. shopee.search Dados de pesquisa por palavra-chave
  3. shopee.live Dados relacionados a lives | | input.url | string | Link URL | Suporta quatro tipos de links URL
  4. O link URL da página de detalhes do produto
  5. O link da API da página de detalhes do produto (/api/v4/pdp/get_pc)
  6. O link da API para pesquisa de produtos (/api/v4/search/search_items)
  7. O link da API para transmissões ao vivo (/api/v1/session/{sessionId}/more_items) |

Dados Detalhes do Produto

import { Scrapeless } from '@scrapeless-ai/sdk';
 
const client = new Scrapeless({
  apiKey: 'YOUR_API_KEY'
});
 
client.scraping.createTask({
   actor: "scraper.shopee",
   input: {
      action: "shopee.product",
      url: "https://shopee.tw/2312312.10228173.24803858474"
   }
}).then(async (result) => {
    console.log(result);
  })
  .catch((error) => {
    console.error('Error:', error);
  });

Dados de Pesquisa de Produtos

import { Scrapeless } from '@scrapeless-ai/sdk';
 
const client = new Scrapeless({
  apiKey: 'YOUR_API_KEY'
});
 
client.scraping.createTask({
   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"
   }
}).then(async (result) => {
    console.log(result);
  })
  .catch((error) => {
    console.error('Error:', error);
  });

Dados de Lives

import { Scrapeless } from '@scrapeless-ai/sdk';
 
const client = new Scrapeless({
  apiKey: 'YOUR_API_KEY'
});
 
const sessionId = "";
client.scraping.createTask({
   actor: "scraper.shopee",
   input: {
      action: "shopee.live",
      url: `https://live.shopee.co.th/api/v1/session/${sessionId}/more_items?offset=0&limit=10`
   }
}).then(async (result) => {
    console.log(result);
  })
  .catch((error) => {
    console.error('Error:', error);
  });

API da Página de Detalhes do Produto

# A API pode ser dividida em três partes
# 1. região
# 2. item_id
# 3. shop_id
 
# Lista de regiões suportadas
# ["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)

API de Pesquisa de Produtos

limit = 20  # 10 20 30 40
order = "desc"
page_type = "search"
keyword = "keyword"   # edite-o
region = "shopee.co.id"
 
# Lista de regiões suportadas
# ["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)

Recuperar Resultados da Tarefa 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)