Skip to content

Commit 7c0c8c1

Browse files
committed
修复采集问题
1 parent 588d671 commit 7c0c8c1

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

lib/rss/weixin.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ Weixin.prototype.getListData = function*(apiUrl) {
7272

7373
var body = response.body;
7474
var match = body.match(/var\smsgList\s=\s'([\s\S]*?)';/);
75-
7675
if (!match || !match[1]) {
7776
throw new Error('无法获取列表数据');
7877
}
@@ -89,6 +88,21 @@ Weixin.prototype.getListData = function*(apiUrl) {
8988
'sourcename' : item.app_msg_ext_info.author
9089
};
9190
items.push(_item);
91+
//subList
92+
var subList = item.app_msg_ext_info.multi_app_msg_item_list;
93+
if (subList.length > 0) {
94+
subList.forEach(function(subItem) {
95+
var _item = {
96+
'docid' : subItem.fileid,
97+
'lastModified' : item.comm_msg_info.datetime,
98+
'title' : subItem.title,
99+
'content' : subItem.digest,
100+
'url' : 'http://mp.weixin.qq.com' + subItem.content_url.substr(1).html(),
101+
'sourcename' : subItem.author
102+
};
103+
items.push(_item);
104+
});
105+
}
92106
});
93107
return items;
94108
}
@@ -119,23 +133,32 @@ Weixin.prototype.getContentData = function*(item) {
119133
});
120134
if (!result.error && result.statusCode == 200) {
121135
var match = result.body.match(/id=\"js_content\">([\s\S]*?)<\/div>/);
136+
var cover = this.getCover(result.body);
122137
if (match && match[1]) {
123138
content = match[1].replace(/data-src/g, 'src');
124-
var coverHtml = item.imglink ? '<p class="article-cover"><img src="' + item.imglink + '"></p>' : '';
139+
var coverHtml = cover ? '<p class="article-cover"><img src="' + cover + '"></p>' : '';
125140
content = coverHtml + content;
126141
return {'content' : content, 'source' : result.request.href};
127142
}
128143
}
129144
}
130145

146+
Weixin.prototype.getCover = function(html) {
147+
var match = html.match(/var\scover\s=\s\"([\s\S]*?)\";/);
148+
if (match && match[1]) {
149+
return match[1];
150+
}
151+
};
152+
131153
Weixin.prototype.getRequestHeaders = function*() {
132154
return {
133155
'Accept': '*/*',
134156
'Accept-Language': 'zh-CN,zh;q=0.8,en;q=0.6',
135157
'Cache-Control': 'max-age=0',
136158
'Connection': 'keep-alive',
137159
'Cookie': 'sd_userid=74761436088560498; sd_cookie_crttime=1436088560498; 3g_guest_id=-9124332030488707072; ts_refer=www.baidu.com/link; ts_uid=1816741185; eas_sid=f1w4I5H7w224X4z3w9J27844g9; _ga=GA1.2.1140860462.1438155424; pgv_pvid=1467256065; o_cookie=527114214; noticeLoginFlag=1; ptui_loginuin=527114214; ptcz=2a4b878f712cb71f3eeb0fda5a3d488fd4688d292820e1485fa04ee62c2c9500; pt2gguin=o0527114214; uin=o0527114214; skey=@k3f0ouWCY; qm_username=527114214; qm_sid=705e43ed71261bdea26e56d389d4d334,cpfgcNUS3Cs4.; ptisp=ctc',
138-
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36'
160+
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36',
161+
'Referer' : 'http://weixin.sogou.com/weixin?type=1&query=%E4%B8%80%E5%85%9C%E7%B3%96&ie=utf8&_sug_=y&_sug_type_=&w=01019900&sut=2112&sst0=1468836385188&lkt=1%2C1468836385080%2C1468836385080'
139162
}
140163
}
141164

0 commit comments

Comments
 (0)