...
|
...
|
@@ -189,7 +189,7 @@ class BaiduLinkSubmit extends global.yoho.BaseModel { |
|
|
})();
|
|
|
}
|
|
|
|
|
|
_getYohoNewsLink(url) {
|
|
|
_getRp(url, json) {
|
|
|
return rp({
|
|
|
method: 'GET',
|
|
|
uri: url,
|
...
|
...
|
@@ -198,7 +198,7 @@ class BaiduLinkSubmit extends global.yoho.BaseModel { |
|
|
encode: false
|
|
|
},
|
|
|
timeout: 8 * 1000,
|
|
|
json: true,
|
|
|
json: json || true,
|
|
|
gzip: true
|
|
|
}).then(result => {
|
|
|
return {
|
...
|
...
|
@@ -207,7 +207,6 @@ class BaiduLinkSubmit extends global.yoho.BaseModel { |
|
|
message: 'success'
|
|
|
};
|
|
|
}).catch(e => {
|
|
|
console.log(`_getYohoNewsLink: err: ${e.message}`);
|
|
|
return {code: e.statusCode || 400, data: [], message: e.message};
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -224,8 +223,9 @@ class BaiduLinkSubmit extends global.yoho.BaseModel { |
|
|
mipUrl: 'http://www.yohoboys.com'
|
|
|
};
|
|
|
|
|
|
let rdata = _.get(yield that._getYohoNewsLink(
|
|
|
`${initData.pcUrl}/channel/ajax/tab?channel=100&page=1`
|
|
|
let rdata = _.get(yield that._getRp(
|
|
|
`${initData.pcUrl}/channel/ajax/tab?channel=100&page=1`,
|
|
|
true
|
|
|
), 'data', []);
|
|
|
let tlinks = [];
|
|
|
let links = _.map(rdata, item => {
|
...
|
...
|
@@ -294,8 +294,9 @@ class BaiduLinkSubmit extends global.yoho.BaseModel { |
|
|
mipUrl: 'http://www.yohogirls.com'
|
|
|
};
|
|
|
|
|
|
let rdata = _.get(yield that._getYohoNewsLink(
|
|
|
`${initData.pcUrl}/channel/ajax/getRecoms?channel=1&page=1`
|
|
|
let rdata = _.get(yield that._getRp(
|
|
|
`${initData.pcUrl}/channel/ajax/getRecoms?channel=1&page=1`,
|
|
|
true
|
|
|
), 'data', []);
|
|
|
let tlinks = [];
|
|
|
let links = _.map(rdata, item => {
|
...
|
...
|
@@ -447,6 +448,54 @@ class BaiduLinkSubmit extends global.yoho.BaseModel { |
|
|
})();
|
|
|
}
|
|
|
|
|
|
// 实时推送mars
|
|
|
marsReal() {
|
|
|
let marsIds = [];
|
|
|
let errId = 0;
|
|
|
let initData = {
|
|
|
mip: [],
|
|
|
pc: [],
|
|
|
pcUrl: 'http://www.yohomars.com',
|
|
|
mipUrl: 'http://www.yohomars.com'
|
|
|
};
|
|
|
|
|
|
// init global:yoho:seo:linksubmit:marsReal 11972
|
|
|
return redis.getAsync('global:yoho:seo:linksubmit:marsReal').then(marsReal => {
|
|
|
marsReal = parseInt(marsReal, 10);
|
|
|
|
|
|
for (let i = 0; i < 5; i++) {
|
|
|
marsIds.push(marsReal);
|
|
|
marsReal = (marsReal + 2);
|
|
|
}
|
|
|
|
|
|
return Promise.each(marsIds, (id) => this._getRp(
|
|
|
`http://www.yohomars.com/share/store/${id}`,
|
|
|
false
|
|
|
).then(result => {
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
initData.pc.push(`http://www.yohomars.com/share/store/${id}`);
|
|
|
initData.mip.push(`http://www.yohomars.com/store/share/mip/${id}.html`);
|
|
|
} else if (!errId && result.code === 404) {
|
|
|
errId = id;
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
})
|
|
|
);
|
|
|
}).then(() => {
|
|
|
errId = errId ? errId : (marsIds.pop() + 2);
|
|
|
|
|
|
// 记录最后一次404或者上次推送成功连接id
|
|
|
return redis.setAsync('global:yoho:seo:linksubmit:marsReal', errId);
|
|
|
}).then(() => {
|
|
|
return Promise.all([
|
|
|
this.sendUrl(initData.pc, initData.pcUrl),
|
|
|
this.sendUrl(initData.mip, initData.mipUrl, 'mip')
|
|
|
]);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
module.exports = BaiduLinkSubmit; |
...
|
...
|
|