采集场景
打开拼多多商品详情页(实例网址:mobile.yangkeduo.com/goods1.html… ),采集点击不同的参数(颜色、版本等)后得到的数据(商品编号、价格、主图链接等字段会随着参数变化而变化)。
采集字段
商品标题、颜色、版本、价格、商品名称、商品编号、图片网址等。
采集结果
采集结果可导出为Excel、CSV、HTML、数据库等多种格式。导出为Excel示例:
Pinduoduo.item_get_app-获得拼多多商品详情原数据接口展示
1.请求方式:HTTP POST GET 、请求链接:c0b.cc/30G0f2
2.请求参数(复制v:Taobaoapi2014 )
请求参数:num_iid=19970108018
参数说明:num_iid:淘宝商品ID
3.请求代码示例,支持高并发请求(CURL、PHP 、PHPsdk 、Java 、C# 、Python...)
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.19970108018.cn/pinduoduo/item_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=1620002566";
JSONObject json = getRequestFromUrl(url);
System.out.println(json.toString());
}
}
4.响应示例