First, how to manually view the data of Taobao product details page.
1. Taobao product details API interface, TaobaoAPI interface code docking can obtain the baby ID, baby title, price, shopkeeper name, inventory, minimum purchase number, baby link, baby picture, brand name, product details, details pictures and other pages of the data can be obtained, manual method is as follows:
For example, we open the mobile Taobao APP or PC, search the keyword "dress", click on a random baby, enter the details of this product, we will recommend this product as an example, click to enter the details of the product page. ↓↓↓
2. Click the right mouse button to view the data parameters of the details page of the source code, including title, pictures, commodity prices, commodity coupons, discount information, inventory quantity, commodity details page data and other parameters.
3.Taobao.item_get - Get product details data interface
3.1Request mode: HTTP POST GET ;View demo address
3.2Request example(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 {
// Request Example URL Default request parameters have been URL-encoded
String url = "Https://api.xxxxx.cn/taobao/item_get/?key= < your own apiKey > & secret = < your own apiSecret > & num_iid = 652874751412 & is_promotion = 1 ";
JSONObject json = getRequestFromUrl(url);
System.out.println(json.toString());
}
}
3.3Response sample
{
"item": {
"num_iid": "520813250866",
"title": "Three-blade wooden folding knife through the security check Creative mini keychain Key knife Saber portable multi-functional knife free mail ",
"desc_short": "",
"price": 25.8,
"total_price": 0,
"suggestive_price": 0,
orginal_price: 25.80,
"nick": "Happy Shop ",
"num": "832",
"min_num": 0,
"detail_url": "http://item.taobao.com/item.htm?id=520813250866",
"pic_url": "//img.alicdn.com/imgextra/i4/2596264565/TB2p30elFXXXXXQXpXXXXXXXXXX_!! 2596264565.jpg",
"brand": "Three-edged wood ",
"brandId": "4036703",
"rootCatId": "50013886",
"cid": "50014822",
"favcount": "4824",
"fanscount": "1469",
"crumbs": [],
"created_time": "",
"modified_time": "",
"delist_time": "",
"desc": " Store all products support lettering, if you need to lettering, contact customer service before shooting.
With bottle opener function , drink without worry. (Key knife without opener function)
Can be used as a tag necklace decoration, also can be used as a key chain hanging decoration, fruit knife opener outdoor self-defense.
Some customers reflect with us that the quality of the chain is not good enough, because
In the above example, the API data of Taobao product details is obtained by sending HTTP /POST/GET bulk requests, and then the returned JSON data is parsed into the corresponding data structure for further processing and use. Note that in practice, you will also need to build requests, handle exceptions, and other implementation details according to Taobao's API documentation and requirements.