Python “hand in hand“ Taobao commodity details data interface, Taobao API.

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": "<p style=\"text-align:center; \"><span style=\"color:#ff0000; \"><span style=\"font-size:24.0px; \"><strong> Store all products support lettering, if you need to lettering, contact customer service before shooting. </strong></span></span></p> <p style=\"text-align:center; "><span style=\"font-size:18.0px; <span style=\"color:#ff0000; <span style=\" \"> With bottle opener function </span>, drink without worry. (Key knife without opener function) </strong></span></p> <p style=\"text-align:center; \"><strong style=\"color:#000000; The line - height: 1.5; "><span style=\"font-size:18.0px; "><span style=\"line-height:18.0px; \"> Can be used as a tag necklace decoration, also can be used as a key chain hanging decoration, fruit knife opener outdoor self-defense.</span></span></strong></p> <p style=\"text-align:center; "><strong style=\"line-height:1.5; \"><span style=\"font-size:24.0px; "> 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值