...
|
...
|
@@ -24,11 +24,11 @@ class BaiduLinkSubmit extends global.yoho.BaseModel { |
|
|
let siteType = '';
|
|
|
|
|
|
if (type === 'mip') {
|
|
|
siteType = 'MIP';
|
|
|
siteType = 'MIP: ';
|
|
|
} else if (site.indexOf('www.yohobuy') > -1) {
|
|
|
siteType = 'PC';
|
|
|
siteType = 'PC: ';
|
|
|
} else if (site.indexOf('m.yohobuy') > -1) {
|
|
|
siteType = 'WAP';
|
|
|
siteType = 'WAP: ';
|
|
|
}
|
|
|
|
|
|
if (!site) {
|
...
|
...
|
@@ -41,7 +41,7 @@ class BaiduLinkSubmit extends global.yoho.BaseModel { |
|
|
|
|
|
return rp({
|
|
|
method: 'POST',
|
|
|
uri: `${senUrl}`,
|
|
|
uri: senUrl,
|
|
|
qs: {
|
|
|
token: '0lSAO4ZxEKsYopMG',
|
|
|
site: site,
|
...
|
...
|
@@ -58,7 +58,7 @@ class BaiduLinkSubmit extends global.yoho.BaseModel { |
|
|
|
|
|
return Object.assign({
|
|
|
code: 200,
|
|
|
message: `${siteType} 当天剩余${result.remain || result.remain_mip}条可推送到百度资源平台,本次成功推送${result.success || result.success_mip}条。` // eslint-disable-line
|
|
|
message: `${siteType}当天剩余${result.remain || result.remain_mip}条可推送到百度资源平台,本次成功推送${result.success || result.success_mip}条。` // eslint-disable-line
|
|
|
}, result);
|
|
|
}).catch(e => {
|
|
|
console.log(e.message);
|
...
|
...
|
@@ -130,7 +130,6 @@ class BaiduLinkSubmit extends global.yoho.BaseModel { |
|
|
|
|
|
// 提交逛详情URL
|
|
|
guangUrl() {
|
|
|
|
|
|
let that = this;
|
|
|
|
|
|
return co(function* () {
|
...
|
...
|
@@ -194,6 +193,140 @@ class BaiduLinkSubmit extends global.yoho.BaseModel { |
|
|
})();
|
|
|
}
|
|
|
|
|
|
_getYohoNewsLink(url) {
|
|
|
return rp({
|
|
|
method: 'GET',
|
|
|
uri: url,
|
|
|
qs: {},
|
|
|
qsStringifyOptions: {
|
|
|
encode: false
|
|
|
},
|
|
|
timeout: 8 * 1000,
|
|
|
json: true,
|
|
|
gzip: true
|
|
|
}).then(result => {
|
|
|
return {
|
|
|
code: 200,
|
|
|
data: result,
|
|
|
message: 'success'
|
|
|
};
|
|
|
}).catch(e => {
|
|
|
console.log(`_getYohoNewsLink: err: ${e.message}`);
|
|
|
return {code: e.statusCode || 400, data: [], message: e.message};
|
|
|
});
|
|
|
}
|
|
|
// 潮流boys
|
|
|
yohoBoys() {
|
|
|
let that = this;
|
|
|
|
|
|
return co(function* () {
|
|
|
let initData = {
|
|
|
pc: [],
|
|
|
pcUrl: 'http://www.yohoboys.com',
|
|
|
};
|
|
|
|
|
|
let rdata = _.get(yield that._getYohoNewsLink(
|
|
|
`${initData.pcUrl}/channel/ajax/tab?channel=100&page=1`
|
|
|
), 'data', []);
|
|
|
let tlinks = [];
|
|
|
let links = _.map(rdata, item => {
|
|
|
return _.get(item, 'content.url', '').replace(/http:|https:/, '');
|
|
|
});
|
|
|
|
|
|
let artice = {
|
|
|
total: links.length,
|
|
|
notAlready: 0
|
|
|
};
|
|
|
|
|
|
links = _.difference(links, yield redis.hmgetAsync('global:yoho:seo:linksubmit:newsBoys', links));// 去除已经推送的
|
|
|
artice.notAlready = links.length;
|
|
|
|
|
|
if (artice.notAlready <= 0) {
|
|
|
let message = `获取${artice.total}条记录,未推送0条,成功推送0条。`;
|
|
|
|
|
|
return {code: 201, data: [], message: message};
|
|
|
}
|
|
|
|
|
|
_.each(links, val => {
|
|
|
if (_.isEmpty(val)) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
tlinks.push(val, val);// mset做准备
|
|
|
|
|
|
initData.pc.push(`http:${val}`);
|
|
|
});
|
|
|
|
|
|
rdata = yield that.sendUrl(initData.pc, initData.pcUrl);
|
|
|
|
|
|
if (_.get(rdata, 'code', 400) !== 200) {
|
|
|
return rdata;
|
|
|
}
|
|
|
|
|
|
yield redis.hmsetAsync('global:yoho:seo:linksubmit:newsBoys', tlinks);
|
|
|
|
|
|
links = [];
|
|
|
tlinks = [];
|
|
|
|
|
|
return rdata;
|
|
|
})();
|
|
|
}
|
|
|
// 潮流girls
|
|
|
yohoGirls() {
|
|
|
let that = this;
|
|
|
|
|
|
return co(function* () {
|
|
|
let initData = {
|
|
|
pc: [],
|
|
|
pcUrl: 'http://www.yohogirls.com',
|
|
|
};
|
|
|
|
|
|
let rdata = _.get(yield that._getYohoNewsLink(
|
|
|
`${initData.pcUrl}/channel/ajax/getRecoms?channel=1&page=1`
|
|
|
), 'data', []);
|
|
|
let tlinks = [];
|
|
|
let links = _.map(rdata, item => {
|
|
|
return _.get(item, 'link', '').replace(/http:|https:/, '');
|
|
|
});
|
|
|
let artice = {
|
|
|
total: links.length,
|
|
|
notAlready: 0
|
|
|
};
|
|
|
|
|
|
links = _.difference(links, yield redis.hmgetAsync('global:yoho:seo:linksubmit:newsGirls', links));// 去除已经推送的
|
|
|
artice.notAlready = links.length;
|
|
|
|
|
|
if (artice.notAlready <= 0) {
|
|
|
let message = `获取${artice.total}条记录,未推送0条,成功推送0条。`;
|
|
|
|
|
|
return {code: 201, data: [], message: message};
|
|
|
}
|
|
|
|
|
|
_.each(links, val => {
|
|
|
if (_.isEmpty(val)) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
tlinks.push(val, val);// mset做准备
|
|
|
|
|
|
initData.pc.push(`http:${val}`);
|
|
|
});
|
|
|
|
|
|
rdata = yield that.sendUrl(initData.pc, initData.pcUrl);
|
|
|
|
|
|
if (_.get(rdata, 'code', 400) !== 200) {
|
|
|
return rdata;
|
|
|
}
|
|
|
|
|
|
yield redis.hmsetAsync('global:yoho:seo:linksubmit:newsGirls', tlinks);
|
|
|
|
|
|
links = [];
|
|
|
tlinks = [];
|
|
|
|
|
|
return rdata;
|
|
|
})();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
module.exports = BaiduLinkSubmit; |
...
|
...
|
|