淘宝关键字搜索接口,是复原我们在淘宝购物时,在搜索栏内输入关键字,即可获取到相关商品列表,商品信息齐全,支持翻页展示。同时,传入参数sort可按价格排序,也可筛选响应价格段的商品。商品信息是千人千面的。
接口名称:item_search
请求地址:https://o0b.cn/jennif
请求参数:
响应参数:
Version: Date:
名称 | 类型 | 必须 | 示例值 | 描述 |
---|---|---|---|---|
title |
String | 0 | 法式复古山本超仙chic仙女赫本网红初春很仙法国小众裙子两件套装 | 商品标题 |
pic_url |
String | 0 | //img.alicdn.com/bao/uploaded/i3/3083218865/O1CN012FMDaiwxkenJGaM_!!0-item_pic.jpg | 宝贝图片 |
promotion_price |
Float | 0 | 178.00 | 优惠价 |
price |
Float | 0 | 178.00 | 价格 |
sales |
Int | 0 | 890 | 销量 |
num_iid |
Bigint | 0 | 577437133060 | 宝贝ID |
sample_id |
String | 0 | 商品风格标识ID | |
seller_nick |
String | 0 | 初穆旗舰店 | 掌柜昵称 |
post_fee |
Float | 0 | 10.00 | 物流费用 |
area |
String | 0 | 山东 | 店铺所在地 |
detail_url |
String | 0 | //detail.tmall.com/item.htm?id=586794298909&ns=1&abbucket=0 | 宝贝链接 |
seller_info |
Mix | 0 | {"level": 99, "shop_type": "B", "user_num_id": "2217148345", "cid": 0, "delivery_score": "", "item_score": "", "score_p": ""} | 卖家信息 |
调用示例:
curl方式
-- 请求示例 url 默认请求参数已经URL编码处理
curl -i "https://api-服务器.cn/taobao/item_search/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&q=女装&start_price=0&end_price=0&page=1&cat=0&discount_only=&sort=&page_size=&seller_info=&nick=&ppath=&imgid=&filter="
PHP
&secret=<您自己的apiSecret>&q=女装&start_price=0&end_price=0&page=1&cat=0&discount_only=&sort=&page_size=&seller_info=&nick=&ppath=&imgid=&filter=";
$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));
?>
PHPsdk
api_url = "http://api-服务器.cn/";
$obapi->api_urls = array("http://api-服务器.cn/","http://api-服务器1.cn/");//备用API服务器
$obapi->api_urls_on = true;//当网络错误时,是否启用备用API服务器
$obapi->api_key = "<您自己的apiKey>";
$obapi->api_secret = "<您自己的apiSecret>";
$obapi->api_version ="";
$obapi->secache_path ="runtime/";
$obapi->secache_time ="86400";
$obapi->cache = true;
$api_data = $obapi->exec(
array(
"api_type" =>"taobao",
"api_name" =>"item_search",
"api_params"=>array (
'q' => '女装',
'start_price' => '0',
'end_price' => '0',
'page' => '1',
'cat' => '0',
'discount_only' => '',
'sort' => '',
'page_size' => '',
'seller_info' => '',
'nick' => '',
'ppath' => '',
'imgid' => '',
'filter' => '',
)
)
);
var_dump($api_data);
?>
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-服务器.cn/taobao/item_search/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&q=女装&start_price=0&end_price=0&page=1&cat=0&discount_only=&sort=&page_size=&seller_info=&nick=&ppath=&imgid=&filter=";
JSONObject json = getRequestFromUrl(url);
System.out.println(json.toString());
}
}