不同语言采集【淘宝1688拼多多API】平台数据的方式

首先我们以taobao商品页面采集商品详情数据为例:

不同语言采集【淘宝1688拼多多API】平台数据的方式_第1张图片

请求方式:HTTPS  POST  GET

请求地址:API接口

请求参数

请求参数:num_iid=669646899650&is_promotion=1

参数说明:num_iid:淘宝商品ID
is_promotion:是否获取取促销价

请求示例

Curl 

	
-- 请求示例 url 默认请求参数已经URL编码处理
curl -i "https://api-gw.onebound.cn/1688/item_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=610947572360"

PHP 

&secret=<您自己的apiSecret>&num_iid=610947572360";
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_ENCODING, "gzip");
var_dump(curl_exec($curl));
?>

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://api-gw.onebound.cn/1688/item_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=610947572360";
		JSONObject json = getRequestFromUrl(url);
		System.out.println(json.toString());
	}

}

响应示例

{
	"item": {
		"num_iid": "669646899650",
		"title": "大码法式复古温柔风连衣裙长款夏季胖妹妹甜美蝴蝶结泡泡袖仙女裙",
		"desc_short": "",
		"price": "39",
		"total_price": 0,
		"suggestive_price": 0,
		"orginal_price": "69.00",
		"nick": "流婉菲旗舰店",
		"num": "200",
		"min_num": 0,
		"detail_url": "https://item.taobao.com/item.htm?id=669646899650",
		"pic_url": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01CGgYpe1jGCymUQJ7I_!!4140484520-0-lubanu-s.jpg",
		"brand": "流婉菲",
		"brandId": "2387753389",
		"rootCatId": "50010404",
		"cid": "50001248",
		"crumbs": [],
		"created_time": "",
		"modified_time": "",
		"delist_time": "",
		"desc": "",
		"desc_img": [
			"https://img.alicdn.com/imgextra/i4/4140484520/O1CN01XLLJfW1jGCnojRRyn_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i4/4140484520/O1CN012FfedL1jGCniNgnCI_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i3/4140484520/O1CN01sIMmZv1jGCymUTzwl_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i2/4140484520/O1CN01ymMJc11jGCymxBw5k_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i3/4140484520/O1CN01mkchrW1jGCyu7xoFS_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i4/4140484520/O1CN01uFpZrJ1jGCyfvvAES_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i2/4140484520/O1CN01e8Rrz91jGCyu7vnVZ_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i2/4140484520/O1CN01qRDhw71jGCyoHLpHO_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i1/4140484520/O1CN01kOJt4x1jGCymxDD6g_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i3/4140484520/O1CN01GknYgb1jGCyiDb275_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i2/4140484520/O1CN01hWZlXt1jGCymUVPEu_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i2/4140484520/O1CN01jFIO4H1jGCykfatfx_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i4/4140484520/O1CN01scJc0S1jGCyiDbhhp_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i1/4140484520/O1CN01ROrw4L1jGCykYj3YJ_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i2/4140484520/O1CN01hKaAlQ1jGCyrILsZy_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i2/4140484520/O1CN01ohNT8W1jGCymUUXEH_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i2/4140484520/O1CN01pO2KTZ1jGCyhU1D3t_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i3/4140484520/O1CN01EugTgW1jGCypDFuML_!!4140484520.jpg",
			"https://img.alicdn.com/imgextra/i2/4140484520/O1CN01cDY2YB1jGCytI4agJ_!!4140484520.jpg"
		],
		"item_imgs": [
			{
				"url": "https://img.alicdn.com/imgextra/i2/4140484520/O1CN01CGgYpe1jGCymUQJ7I_!!4140484520-0-lubanu-s.jpg"
			},
			{
				"url": "https://img.alicdn.com/imgextra/i2/4140484520/O1CN01bi1AWG1jGCykfaQNb_!!4140484520-0-lubanu-s.jpg"
			},
			{
				"url": "https://img.alicdn.com/imgextra/i4/4140484520/O1CN01XN6Ku11jGCyiDY52p_!!4140484520-0-lubanu-s.jpg"
			},
			{
				"url": "https://img.alicdn.com/imgextra/i1/4140484520/O1CN01U8knGU1jGCys4Jw7I_!!4140484520-0-lubanu-s.jpg"
			},
			{
				"url": "https://img.alicdn.com/imgextra/i1/4140484520/O1CN01VpVOLH1jGCyiDXCzw_!!4140484520-0-lubanu-s.jpg"
			}
		],
		"item_weight": "",
		"item_size": "",
		"location": "广东广州",
		"post_fee": 0,
		"express_fee": null,
		"ems_fee": "",
		"shipping_to": "",
		"has_discount": "true",
		"video": {
			"url": null
		},
		"is_virtual": "",
		"sample_id": "",
		"is_promotion": "true",
		"props_name": "1627207:3232481:颜色分类:杏色S;1627207:90554:颜色分类:杏色M;1627207:28332:颜色分类:杏色L;1627207:30156:颜色分类:杏色XL;1627207:60092:颜色分类:杏色2XL;1627207:3232482:颜色分类:白色S;1627207:3232478:颜色分类:白色M;1627207:3232479:颜色分类:白色L;1627207:28340:颜色分类:白色XL;1627207:28320:颜色分类:白色2XL",
		"prop_imgs": {
			"prop_img": [
				{
					"properties": "1627207:3232481",
					"url": "//img.alicdn.com/imgextra/i4/4140484520/O1CN013RCqQS1jGCymx82im_!!4140484520.jpg"
				},
				{
					"properties": "1627207:90554",
					"url": "//img.alicdn.com/imgextra/i4/4140484520/O1CN013RCqQS1jGCymx82im_!!4140484520.jpg"
				},
				{
					"properties": "1627207:28332",
					"url": "//img.alicdn.com/imgextra/i4/4140484520/O1CN013RCqQS1jGCymx82im_!!4140484520.jpg"
				},
				{
					"properties": "1627207:30156",
					"url": "//img.alicdn.com/imgextra/i4/4140484520/O1CN013RCqQS1jGCymx82im_!!4140484520.jpg"
				},
				{
					"properties": "1627207:60092",
					"url": "//img.alicdn.com/imgextra/i4/4140484520/O1CN013RCqQS1jGCymx82im_!!4140484520.jpg"
				},
				{
					"properties": "1627207:3232482",
					"url": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01SCNBHm1jGCytHykh3_!!4140484520.jpg"
				},
				{
					"properties": "1627207:3232478",
					"url": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01SCNBHm1jGCytHykh3_!!4140484520.jpg"
				},
				{
					"properties": "1627207:3232479",
					"url": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01SCNBHm1jGCytHykh3_!!4140484520.jpg"
				},
				{
					"properties": "1627207:28340",
					"url": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01SCNBHm1jGCytHykh3_!!4140484520.jpg"
				},
				{
					"properties": "1627207:28320",
					"url": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01SCNBHm1jGCytHykh3_!!4140484520.jpg"
				}
			]
		},
		"property_alias": "",
		"props": [
			{
				"name": "品牌",
				"value": "流婉菲"
			},
			{
				"name": "颜色分类",
				"value": "杏色S 杏色M 杏色L 杏色XL 杏色2XL 白色S 白色M 白色L 白色XL 白色2XL"
			},
			{
				"name": "上市时间",
				"value": "2022年夏季"
			},
			{
				"name": "货号",
				"value": "02028"
			}
		],
		"total_sold": "77",
		"skus": {
			"sku": [
				{
					"price": "39",
					"total_price": 0,
					"orginal_price": "39",
					"properties": "1627207:3232481",
					"properties_name": "1627207:3232481:颜色分类:杏色S",
					"quantity": "200",
					"sku_id": "4859708472517"
				},
				{
					"price": "39",
					"total_price": 0,
					"orginal_price": "39",
					"properties": "1627207:90554",
					"properties_name": "1627207:90554:颜色分类:杏色M",
					"quantity": "200",
					"sku_id": "4859708472520"
				},
				{
					"price": "39",
					"total_price": 0,
					"orginal_price": "39",
					"properties": "1627207:28332",
					"properties_name": "1627207:28332:颜色分类:杏色L",
					"quantity": "200",
					"sku_id": "4859708472514"
				},
				{
					"price": "39",
					"total_price": 0,
					"orginal_price": "39",
					"properties": "1627207:30156",
					"properties_name": "1627207:30156:颜色分类:杏色XL",
					"quantity": "200",
					"sku_id": "4859708472516"
				},
				{
					"price": "39",
					"total_price": 0,
					"orginal_price": "39",
					"properties": "1627207:60092",
					"properties_name": "1627207:60092:颜色分类:杏色2XL",
					"quantity": "200",
					"sku_id": "4859708472519"
				},
				{
					"price": "39",
					"total_price": 0,
					"orginal_price": "39",
					"properties": "1627207:3232482",
					"properties_name": "1627207:3232482:颜色分类:白色S",
					"quantity": "200",
					"sku_id": "4859708472518"
				},
				{
					"price": "39",
					"total_price": 0,
					"orginal_price": "39",
					"properties": "1627207:3232478",
					"properties_name": "1627207:3232478:颜色分类:白色M",
					"quantity": "200",
					"sku_id": "4990394991054"
				},
				{
					"price": "39",
					"total_price": 0,
					"orginal_price": "39",
					"properties": "1627207:3232479",
					"properties_name": "1627207:3232479:颜色分类:白色L",
					"quantity": "200",
					"sku_id": "4990394991055"
				},
				{
					"price": "39",
					"total_price": 0,
					"orginal_price": "39",
					"properties": "1627207:28340",
					"properties_name": "1627207:28340:颜色分类:白色XL",
					"quantity": "200",
					"sku_id": "4859708472515"
				},
				{
					"price": "39",
					"total_price": 0,
					"orginal_price": "39",
					"properties": "1627207:28320",
					"properties_name": "1627207:28320:颜色分类:白色2XL",
					"quantity": "200",
					"sku_id": "4859708472513"
				}
			]
		},
		"seller_id": "4140484520",
		"sales": 94,
		"shop_id": "461815424",
		"props_list": {
			"1627207:3232481": "颜色分类:杏色S",
			"1627207:90554": "颜色分类:杏色M",
			"1627207:28332": "颜色分类:杏色L",
			"1627207:30156": "颜色分类:杏色XL",
			"1627207:60092": "颜色分类:杏色2XL",
			"1627207:3232482": "颜色分类:白色S",
			"1627207:3232478": "颜色分类:白色M",
			"1627207:3232479": "颜色分类:白色L",
			"1627207:28340": "颜色分类:白色XL",
			"1627207:28320": "颜色分类:白色2XL"
		},
		"seller_info": {
			"nick": "流婉菲旗舰店",
			"item_score": "4.6 ",
			"score_p": "4.7 ",
			"delivery_score": "4.7 ",
			"shop_type": "B",
			"user_num_id": "4140484520",
			"sid": "461815424",
			"title": "流婉菲旗舰店",
			"zhuy": "https://shop461815424.taobao.com/",
			"shop_name": "流婉菲旗舰店"
		},
		"tmall": true,
		"error": "",
		"warning": "",
		"url_log": [],
		"fav_count": "4260",
		"fans_count": "4.3万",
		"freight": "快递: 免运费",
		"props_imgs": {
			"prop_img": [
				{
					"properties": "1627207:3232481",
					"url": "//img.alicdn.com/imgextra/i4/4140484520/O1CN013RCqQS1jGCymx82im_!!4140484520.jpg"
				},
				{
					"properties": "1627207:90554",
					"url": "//img.alicdn.com/imgextra/i4/4140484520/O1CN013RCqQS1jGCymx82im_!!4140484520.jpg"
				},
				{
					"properties": "1627207:28332",
					"url": "//img.alicdn.com/imgextra/i4/4140484520/O1CN013RCqQS1jGCymx82im_!!4140484520.jpg"
				},
				{
					"properties": "1627207:30156",
					"url": "//img.alicdn.com/imgextra/i4/4140484520/O1CN013RCqQS1jGCymx82im_!!4140484520.jpg"
				},
				{
					"properties": "1627207:60092",
					"url": "//img.alicdn.com/imgextra/i4/4140484520/O1CN013RCqQS1jGCymx82im_!!4140484520.jpg"
				},
				{
					"properties": "1627207:3232482",
					"url": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01SCNBHm1jGCytHykh3_!!4140484520.jpg"
				},
				{
					"properties": "1627207:3232478",
					"url": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01SCNBHm1jGCytHykh3_!!4140484520.jpg"
				},
				{
					"properties": "1627207:3232479",
					"url": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01SCNBHm1jGCytHykh3_!!4140484520.jpg"
				},
				{
					"properties": "1627207:28340",
					"url": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01SCNBHm1jGCytHykh3_!!4140484520.jpg"
				},
				{
					"properties": "1627207:28320",
					"url": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01SCNBHm1jGCytHykh3_!!4140484520.jpg"
				}
			]
		},
		"_ddf": "xdl",
		"promo_type": null,
		"props_img": {
			"1627207:3232481": "//img.alicdn.com/imgextra/i4/4140484520/O1CN013RCqQS1jGCymx82im_!!4140484520.jpg",
			"1627207:90554": "//img.alicdn.com/imgextra/i4/4140484520/O1CN013RCqQS1jGCymx82im_!!4140484520.jpg",
			"1627207:28332": "//img.alicdn.com/imgextra/i4/4140484520/O1CN013RCqQS1jGCymx82im_!!4140484520.jpg",
			"1627207:30156": "//img.alicdn.com/imgextra/i4/4140484520/O1CN013RCqQS1jGCymx82im_!!4140484520.jpg",
			"1627207:60092": "//img.alicdn.com/imgextra/i4/4140484520/O1CN013RCqQS1jGCymx82im_!!4140484520.jpg",
			"1627207:3232482": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01SCNBHm1jGCytHykh3_!!4140484520.jpg",
			"1627207:3232478": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01SCNBHm1jGCytHykh3_!!4140484520.jpg",
			"1627207:3232479": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01SCNBHm1jGCytHykh3_!!4140484520.jpg",
			"1627207:28340": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01SCNBHm1jGCytHykh3_!!4140484520.jpg",
			"1627207:28320": "//img.alicdn.com/imgextra/i2/4140484520/O1CN01SCNBHm1jGCytHykh3_!!4140484520.jpg"
		},
		"format_check": "ok",
		"shop_item": [],
		"relate_items": []
	},
	"error": "",
	"secache": "02169582838adc0f9ff3a60f0d7b8d85",
	"secache_time": 1689234805,
	"secache_date": "2023-07-13 15:53:25",
	"translate_status": "",
	"translate_time": 0,
	"language": {
		"default_lang": "cn",
		"current_lang": "cn"
	},

你可能感兴趣的:(java,开发语言,商品详情API接口,json,python,php)