$(document).ready(function() { var all = 0; var success = 0; var failed = 0; var daysProcessed = [0, 0, 0, 0, 0, 0, 0]; var daysScore = [0, 0, 0, 0, 0, 0, 0]; var daysComments = [0, 0, 0, 0, 0, 0, 0]; function processPage(url) { $.ajax({url: url, success: function(data) { if (data.indexOf(' ') != -1) { failed++; $('#failed').text(failed); return; } try { $('#loader').html(data); } catch(e) {} setTimeout(function() { var score = $('.score:first').text(); if (score != '' && score.charCodeAt(0) != 8212) { var sign = 1; if (score.charCodeAt(0) == 8211) { sign = -1; score = score.substr(1); } var intScore = sign * parseInt(score); var comments = $('#comments_count').text(); var intComments = parseInt(comments); if (intComments > 0 && sign == 1) { //Do we need only positive? var date = $('time:first').attr('datetime'); date = new Date(date); var intDay = date.getDay(); success++; $('#success').text(success); daysProcessed[intDay]++; daysScore[intDay] += intScore; daysComments[intDay] += intComments; $('#processed_' + intDay).text(daysProcessed[intDay]); $('#score_' + intDay).text(daysScore[intDay]); $('#comments_' + intDay).text(daysComments[intDay]); } else { failed++; $('#failed').text(failed); } } else { failed++; $('#failed').text(failed); } }, 1); }, async: false, error: function () { failed++; $('#failed').text(failed); }}); } var i = 153000; var interval = setInterval(function() { try { processPage('http://habrahabr.ru/post/' + i + '/'); } catch (e) { failed++; $('#failed').text(failed); } all++; $('#all').text(all); i--; if (i < 90000) { clearInterval(interval); } }, 0); });
<html> <head> <script type="text/javascript" src="http://yandex.st/jquery/1.8.2/jquery.js"></script> <script type="text/javascript"> //, </script> </head> <body> <div>All processed: <span id="all">0</span></div> <div>All success: <span id="success">0</span></div> <div>All failed: <span id="failed">0</span></div> <br> <div>Mondays processed: <span id="processed_1">0</span></div> <div>Mondays total score: <span id="score_1">0</span></div> <div>Mondays total comments: <span id="comments_1">0</span></div> <br> <div>Tuesdays processed: <span id="processed_2">0</span></div> <div>Tuesdays total score: <span id="score_2">0</span></div> <div>Tuesdays total comments: <span id="comments_2">0</span></div> <br> <div>Wednesdays processed: <span id="processed_3">0</span></div> <div>Wednesdays total score: <span id="score_3">0</span></div> <div>Wednesdays total comments: <span id="comments_3">0</span></div> <br> <div>Thursdays processed: <span id="processed_4">0</span></div> <div>Thursdays total score: <span id="score_4">0</span></div> <div>Thursdays total comments: <span id="comments_4">0</span></div> <br> <div>Fridays processed: <span id="processed_5">0</span></div> <div>Fridays total score: <span id="score_5">0</span></div> <div>Fridays total comments: <span id="comments_5">0</span></div> <br> <div>Saturdays processed: <span id="processed_6">0</span></div> <div>Saturdays total score: <span id="score_6">0</span></div> <div>Saturdays total comments: <span id="comments_6">0</span></div> <br> <div>Sundays processed: <span id="processed_0">0</span></div> <div>Sundays total score: <span id="score_0">0</span></div> <div>Sundays total comments: <span id="comments_0">0</span></div> <div id="loader" style="display:none"></div> </body> </html>
Day of the week | Total posts | pros | Comments | Pros / Posts | Comments / Posts |
---|---|---|---|---|---|
Monday | 3637 | 136035 | 178084 | 37.40 | 48.96 |
Tuesday | 3719 | 140566 | 194264 | 37.79 | 52.23 |
Wednesday | 3702 | 135767 | 184081 | 36.67 | 49.72 |
Thursday | 3507 | 128936 | 178940 | 36.76 | 51.02 |
Friday | 3506 | 131063 | 170025 | 37.38 | 48.49 |
Saturday | 1573 | 64073 | 85372 | 40.73 | 54.27 |
Sunday | 1545 | 72376 | 91465 | 46.84 | 59.20 |
Source: https://habr.com/ru/post/153995/
All Articles