Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save suhaotian/dafa187e1e87e5ea1cf0 to your computer and use it in GitHub Desktop.
Save suhaotian/dafa187e1e87e5ea1cf0 to your computer and use it in GitHub Desktop.
var result = [];
var phoneTypes = [];
var filters = ['微博', 'Android'];
var baseUrl = 'http://m.weibo.cn/single/rcList?format=cards&id=3877877018124939&type=comment&hot=1&page=';
var userUrl = 'http://weibo.com/u/'
function getPage(i) {
var url = baseUrl + i;
$.get(url, function(res){
var groups;
if(res.length == 2) {
groups = res[1].card_group;
} else {
groups = res[0].card_group;
}
if(!groups) {
console.log('抓取完毕!一共:' + (i+1) + '页');
return ;
}
parseGroups(groups, i);
})
}
function parseGroups(groups, i) {
groups.forEach(function(item){
var source = item.source, text = item.text;
phoneTypes.push(source);
if(source.indexOf('iPhone')>-1 || source.indexOf('iPad')>-1 || source.indexOf('荣耀')>-1) {return;}
if(source.indexOf('微博')>-1 || source.indexOf('Android')>-1 || text.indexOf('虐')>-1) {
var user = {source: source, screen_name: item.user.screen_name, id: item.user.id, text: text};
result.push(user);
console.log(i);
console.log([item.user.screen_name, item.user.id, text, source]);
}
});
i++;
setTimeout(function(){getPage(i)}, 1500);
}
function init() {
var i = 0;
getPage(i);
}
init()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment