Answer the question
In order to leave comments, you need to log in
Who wants to write a script to collect statistics from the first Habrakamp?
Habrakamp here
habrahabr.ru/post/148795/
Actually, any statistics will be interesting:
top by pluses
top by number of questions
top by number of answers
top by minuses
top by most active whys
and any other statistics that you come up with.
Answer the question
In order to leave comments, you need to log in
Cheap Fast and angry:
$ ./parse.sh http://habrahabr.ru/post/148795/ | column -t
Now_is: Wed_Aug_1_00:28:55_MSK_2012
The_url_is: http://habrahabr.ru/post/148795/
Max_"+"_is: 13 RxB
Max_"-"_is: 30 Gangsta
Total_comments: 721
Top_commentor_is: 49 opium
Total_questions: 342
Total_links: 57
Most_popular_site_is: 4 http://twower.livejournal.com
Total_commentators: 189
Total_"+": 495
Total_"-": 101
Total_Sign: 394
#!/bin/sh
v_temp=`mktemp`
echo -n "Now_is: "
date | sed 's/\s\+/_/g'
echo "The_url_is: $1"
wget -q --referer="http://www.google.com" --user-agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6" -O $v_temp "$1"
sed -i '/comments_list/,/for_users_only_msg/!d' $v_temp
echo -n 'Max_"+"_is: '
sed -n "/class=\"\(score\|username\)\"/p" $v_temp | sed 'N;s/<[^>]*>//g;s/\n//;s/^\s\++//;/^\s\+–/d' | sort -n | tail -1
echo -n 'Max_"-"_is: '
sed -n "/class=\"\(score\|username\)\"/p" $v_temp | sed 'N;s/<[^>]*>//g;s/\n//;s/^\s\+–//;/^\s\++/d' | sort -n | tail -1
echo -n 'Total_comments: '
sed -n '/class="score"/p' $v_temp | wc -l
echo -n 'Top_commentor_is: '
grep username $v_temp | sort | uniq -c | sort -n | tail -1 | sed 's/<[^>]*>//g;'
echo -n 'Total_questions: '
sed -n 's)<[^>]*>))g;/\?/p' $v_temp | wc -l
echo -n 'Total_links: '
sed -n '/message html_format/,/^\s\+<\/div>/{s><a href>\n&>;/a href/p}' $v_temp | grep "a href" | wc -l
echo -n 'Most_popular_site_is: '
sed -n '/message html_format/,/^\s\+<\/div>/{s><a href>\n&>;/a href/p}' mktemp | egrep -o 'https?://[^/"]*' | sort | uniq -c | sort -n | grep -v habr | tail -1
echo -n 'Total_commentators: '
sed -n '/class="username"/p' $v_temp | sort -u | wc -l
echo -n 'Total_"+": '
sed -n '/class="score"/{s/.*uarr;\([0-9]\+\).*/\1/;p}' $v_temp | awk '{sum+=$1}END{print sum}'
echo -n 'Total_"-": '
sed -n '/class="score"/{s/.*darr;\([0-9]\+\).*/\1/;p}' $v_temp | awk '{sum+=$1}END{print sum}'
echo -n 'Total_Sign: '
sed -n '/class="score"/{s/.*uarr;\([0-9]\+\).*darr;\([0-9]\+\)/\1 \2/;p}' $v_temp | awk '{plus+=$1;minus+=$2}END{print plus-minus}'
rm $v_temp
Some statistics at the time of 11:00 - 12:00 (MSK)
I don't know if this is related to statistics or not, but my answers about the army gave +5 pluses to karma. To be honest, I didn’t expect it, I thought it would be the other way around (the army on Habré is a rather dangerous topic, I was already merged once)
Some statistics at the time of 11:00 - 12:00 (MSK)
Here you can execute such js. And messages will be grouped by questions and answers, as well as “Top Pluses” and “Top Questions” will appear. But the truth is terribly slow when executing it in the firebug console. And I didn't bother much with the appearance.
{
var plusArr={},questArr={};
$('#comments > div.comment_item').each(function(i,el){
el=$(el);
var r=el.children('div.reply_comments'),
rb=el.children('div.reply'),
m=el.children('div.message'),
info=el.children('div.info'),
qs=r.children('div.comment_item'),
show=$('<a>Вопросы</a>').insertAfter(m),
user=$('a.username',info).text(),
score=parseInt($('span.score',info).text());
el.css('border','1px solid green');
r.hide();
rb.hide();
show.toggle(function(){
r.show();rb.show();
},function(){
r.hide();rb.hide();
});
$('a.reply',rb).text('Спросить');
qs.each(function(i,el){
el=$(el);
var r=el.children('div.reply_comments'),
rb=el.children('div.reply'),
m=el.children('div.message'),
info=el.children('div.info'),
user=$('a.username',info).text(),
show=$('<a>Ответы</a>').insertAfter(m),
localscore=0;
el.css('border','1px solid blue');
r.hide();
rb.hide();
show.toggle(function(){
r.show();rb.show();
},function(){
r.hide();rb.hide();
});
$('div.info:has(a.username:[text="'+user+'"]) span.score',r).each(function(i,el){
localscore+=parseInt($(el).text());
});
score+=localscore;
show.text('Ответы ('+r.children('div.comment_item').length+')');
var stat='';
stat+='<span> За ответы:'+((localscore>0)?'+':'')+localscore+'</span>';
$(stat).appendTo(info);
if(!questArr[user]) questArr[user]=1;
else questArr[user]++;
});
show.text('Вопросы ('+qs.length+')');
var stat='';
stat+='<span> За ответы:'+((score>0)?'+':'')+score+'</span>';
$(stat).appendTo(info);
});
var getTop =function(obj,n){
var a=[];
for(var i in obj)
a.push({n:i,v:obj[i]});
a.sort(function(a,b){return b.v-a.v;});
return a.slice(0,n);
}
var makeTopHtml=function(a){
for(var i=0,n=a.length;i<n;i++){
var o=a[i];
a[i]=o.n+': '+o.v;
}
return a.join(', ');
}
$('#comments div.info').each(function(i,el){
var info=$(el),
score=parseInt($('span.score',info).text());
if(score!=0){
var user=$('a.username',info).text();
if(!plusArr[user]) plusArr[user]=0;
plusArr[user]+=score;
}
});
var stat='';
stat+='<div> Топ Плюсов:'+makeTopHtml(getTop(plusArr,10))+'</div>';
stat+='<div> Топ Вопросов:'+makeTopHtml(getTop(questArr,10))+'</div>';
$(stat).insertBefore($('#comments'));
}
In general, it is difficult to determine from the current html where the question is and where the answer is. This is clear only at the first two levels, and then someone can ask, and someone can answer. It seems to me that Habrakamp needs a new message structure, so that when you write a message, you must explicitly indicate whether this is a question or an answer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question