var http = require('http');
var querystring = require('querystring');
var fs = require('fs');
var data = '{"uid":"502acbd07fc640768ac3621bfaa55be4","pageSize":10,"pageIndex":0}';
var moment = require('moment');
var shijian = moment().format('YYYYMMDD')
console.log(shijian);
var options = {
hostname: '016888.net',
port: 80, //端口号 https 默认端口 443,http 默认的端口号是 80
path: '/personProduct/getPersonProductByType.action',
method: 'POST',
headers: {'Connection': 'keep-alive','User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36',
'Content-Type': 'application/json;charset=UTF-8',
'Accept': 'application/json, text/javascript',
'Content-Length': 70}
};
var req=http.request(options,function(res){
res.setEncoding('utf-8');
var responseString = '';
res.on('data', function(data) {
responseString += data;
});
res.on('end', function() {
var resultObject = JSON.parse(responseString);
for(var i=0;i < resultObject.data.rows.length;i++){
var r=resultObject.data.rows[i];
for (var b = 0; b < r.pics.picList.length; b++) {
console.log(r.pics.picList[b]+'保存完成');
fs.writeFile('./imgs/'+shijian+'_'+r.code+'_'+b+'.jpg',r.pics.picList[b],'binary', function (err) {
if (err) throw err;
});
}
}
});
req.on('error', function(e) {
console.log('-----error-------',e);
});
});
req.write(data);
req.end();
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.