Java代码虾皮item_search-根据关键词获取商品列表 API 接口(title商品标题、pic_url宝贝图片、detail_url宝贝链接、shop_id店铺ID、num_iid宝贝ID等_Text

Shopee是东南亚最大的电商平台之一。Shopee拥有商品种类,包括电子消费品、家居、美容保健、母婴、服饰及健身器材等。

做好shopee店铺需要注意以下几点:1.选择优质的产品 2.每日上新产品 3.营销策略 4.引流策略5.发货的地点


Java代码操作示例


import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.io.Reader;

import java.net.URL;

import java.nio.charset.Charset;

import org.json.JSONException;

import org.json.JSONObject;

import java.io.PrintWriter;

import java.net.URLConnection;

public class Example {

private static String readAll(Reader rd) throws IOException {

 StringBuilder sb = new StringBuilder();

 int cp;

 while ((cp = rd.read()) != -1) {

  sb.append((char) cp);

 }

 return  sb.toString();

}

public static JSONObject postRequestFromUrl(String url, String body) throws IOException, JSONException {

 URL realUrl = new URL(url);

 URLConnection conn = realUrl.openConnection();

 conn.setDoOutput(true);

 conn.setDoInput(true);

 PrintWriter out = new PrintWriter(conn.getOutputStream());

 out.print(body);

 out.flush();

 InputStream instream = conn.getInputStream();

 try {

  BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));

  String jsonText = readAll(rd);

  JSONObject json = new JSONObject(jsonText);

  return json;

 } finally {

  instream.close();

 }

}

public static JSONObject getRequestFromUrl(String url) throws IOException, JSONException {

 URL realUrl = new URL(url);

 URLConnection conn = realUrl.openConnection();

 InputStream instream = conn.getInputStream();

 try {

  BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));

  String jsonText = readAll(rd);

  JSONObject json = new JSONObject(jsonText);

  return json;

 } finally {

  instream.close();

 }

}

public static void main(String[] args) throws IOException, JSONException {

 // 请求示例 url 默认请求参数已经URL编码处理

 String url = "https://v-x-;PNG_WNMN/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&q=dress&page=1&sort=&country=.com.my";

 JSONObject json = getRequestFromUrl(url);

 System.out.println(json.toString());

}

}

请求参数


请求参数:q=dress&page=1&sort=&country=.com.my


参数说明:q:搜索关键词-country:网站后缀(.com.my;.vn;.ph),

sort:排序[bid,_bid,_sale,new]

 (bid:总价,sale:销量,new:新品,加_前缀为从大到小排序)

page:页数



响应参数


Version: Date:


名称 类型 必须 示例值 描述

items


item[] 0 根据关键词取商品列表

title


String 0 Real Shot Long Dress Female Summer New Womens Waist Slimming Dress Summer Temperament Dress Popular Fake Two-Piece Dres 商品标题

pic_url


String 0 https://cf.shopee.com.my/file/902d7fd4f24d056d89163e4f32fcc8c2 宝贝图片

promotion_price


Float 0 82.00 优惠价

price_range


Float 0 0 折扣价

price


Float 0 82.00 价格

sales


Int 0 0 销量

num_iid


Bigint 0 334425154/8200081234 宝贝ID

shop_id


Bigint 0 334425154 店铺ID

area


String 0 Kuala Lumpur 店铺所在地

detail_url


String 0 https://shopee.com.my/product/334425154/8200081234 宝贝链接

文章内容有限,欢迎广大码友私信沟通交流!