Скрипт для чтения комментариев любого пользователя
Навеяно постом http://old.reactor.cc/post/3643230
Вкратце: пользователь muted решил написать скрипт (вот этот), который обрабатывает его комментарии: формирует .csv-файл с таблицей, куда включены данные по каждому из комментариев, а также .html-файл, представляющий собой интерактивный график с кликабельными точками, соответствующими тому или иному комменту.
Я же на его основе решил написать ещё один, вынимающий комментарии любого пользователя Реактора и данные по ним (ссылка)
На вход этому скрипту подаётся юзернейм или же ссылка на профиль пользователя. Результат - .xlsx-файл - таблица с подробными данными по комментариям - и интерактивный график по аналогии с первоначальным скриптом
Как этим воспользоваться?
Для работы этого скрипта нужен Python (проверял на версии 3.6) и либы к нему (написаны в заголовке скрипта), а также скачать скрипт как .py-файл (кнопка clone в заголовке пасты на Pastebin). Когда все эти действия совершены, можно приступать.
Для работы скрипта в Windows можно использовать командную строку. При этом необходимо вначале указать конкретную папку, куда программа будет записывать выходные файлы. После чего указывается путь к интерпретатору Python, потом через пробел путь к скрипту, чтобы запустить его:
type 2 to enable continuation mode
type 3 to enable updating mode
>>
or paste the link to his or her profile
type 1 to do the first thing and type 2 to do the other one
>>
Режимы работы скрипта
Второй режим (continuation mode)
Этот режим нужен, если по какой-то причине запись комментариев прервалась раньше времени. Как им воспользоваться?>>
Третий режим (updating mode)
Этот режим нужен, если ранее была записана таблица всех комментариев какого-то пользователя, но с тех пор прошло достаточно много времени, и хотелось бы обновить таблицу новыми комментами. Воспользоваться им можно следующим образом:И немного данных напоследок
Проанализированы комментарии следующих пользователей (с ссылками на таблицы и графиками по ним):Подробнее
e s. Администратор: C:\Windows\system32\cmd.exe_____________________ Microsoft Windows [Version 6.1.7601] (с) Корпорация Майкрософт (Microsoft Corp.), 2009. Все права защищены. С :\Users\asus>D: D:\>cd D:\iiii\testtest D:\iiii\testtest>python.exe D:\jr_comments_l.py
|о!П Администратор: C:\Windows\system32\cmd.exe - python.exe D:\jr_comments_l.py Microsoft Windows [Version 6.1.7601] (с) Корпорация Майкрософт (Microsoft Corp.), 2009. Все права защищены. С:\Users\asus>D: D:\>cd D:\iiii\testtest D:\iiii\testtest>python.exe D:\jr_comments_l.py type 1 to enable reading mode type 2 to enable continuation mode type 3 to enable updating mode »1 you have two options now: you can either enter username or paste the link to his or her profile type 1 to do the first thing and type 2 to do the other one »1 Enter a username »procxela
|ct AflMHHHCTparop: C:\Windows\system32\cmd.exe - python.exe D:\jr_comments_l.py Enter a username »procxela page number 1 /324404l#commentl4922119 /3244647#comment14921829 /3244647#commentl4921842 /3244647#comment14921948 /3244647#comment14921976 /3244647#comment14921998 /3244647#comment14921896 /3244647#commentl4921972 /3244647#comment14921986 /3244647#comment14921905 /3244647#commentl4922006 page number 2 /3243889#commentl4921703 /3244502#commentl4921075 /3244502#commentl4921245 /3244502#commentl4921453 /3244321#commentl4921089 page number 3 /3244363#commentl4920431 /3244363#commentl4920467 completed completed completed completed completed completed completed completed completed completed completed completed completed completed completed completed completed completed
100 50 0 -50 • • ! Mar 2017 May 2017 •• • Jul 2017 Sep 2017 ••
D: \iiii\testtest2>python.exe D:\jr_comments_l.py type 1 to enable reading mode type 2 to enable continuation mode type 3 to enable updating mode »2 Enter name of the excel file or paste path to it »data backup, xlsx Enter number of the last page you successfully saved »
log.txt — Блокнот Файл Правка Формат Вид Справка JnJxJ /3234926#commentl4873736 /3234910#commentl4873537 /3234384#commentl4871355 /3233471#comment14866248 /3231246#comment14856722 /3231246#comment14856613 /3230788#commentl4856331 /32307 88#commentl485 5 page number 60 /3231061#commenm5856 /32 30928#commen«.4^ 5 /3230181#commentl48SL848 completed /3228907#commentl484»69 completed /3228907#commentl4848#86 completed /3228907#commentl4845^44 completed /3229080#comment1484^005 /3227817#commentl4»2969 /3228536#commenti #842942 page number 61i^p /3226429#commenW&32916 completed /3225877#commenrL 48^1671 completed /3225877#commentl483fc746 completed /322 5945#commentl483Qf96 completed /322 5945#commentl483li62 completed /322 5900#commentl483(j|04 compl eted /3224104#commentl483£575 completed /322 5450#commentl48|P426 completed saving excel file.^.^ Successfully savecT^B-“““"^^^^ completed completed completedT] completed completed completed completed completed completed искомое значение completed completed completed /322 5683?Ш11111УМ114'829< /3225713#comment14829846 page number 62 /3223766#commentl4821760 completed сообщение об успеш ном сохранении U
Enter number of the last page you successfully saved »60 page number 61 /3225713#commentl4829846 completed page number 62 !/3223766#commentl4821760 completed /3223326#commentl4819695 completed /3223326#commentl4819765 completed /3222714#commentl4816200 completed /3222714#commentl4816268 completed /3222714#commentl4816488 completed /3222714#commentl4819619 completed /3222545#commentl4815743 completed
150 100 50 • -50 -100 2014 2015 2016 2017 2018 Export to plotly »
80 60 40 20 0 -20 Jul 2015 Jan 2016 Jul 2016 Jan 2017 Jul 2017 Jan 2018 Jul 2018 Export to plot.ly »
100 80 60 40 20 0 V тшшшшдш -20 -40 2010 2012 2014 Export to plotly
80 -40 -60 2014 2015 2016 2017 2018 2019 Export to plotly » • ••
100 -50 Jul 2015 Jan 2016 Jul 2016 Jan 2017 Jul 2017 Jan 2018 Jul 2018 Export to plotly »
50 0----—Л~*—»«у Ч <—%■ -50 -100 Jul 2015 Jan 2016 Jul 2016 Jan 2017 Jul 2017 Jan 2018 Jul 2018 Export to plotly »
80 -40 2014 2015 2016 • • 2017 2018 2019 Export to plotly »
150 100 50 i •Л • # *• i* Va и •••••• •• • % шШШ.ÊÊàMà л - • • • • ч* * г :• % -50 Jan 2015 Jul 2015 Jan 2016 Jul 2016 Jan 2017 Jul 2017 Jan 2018 Jul 2018 Export to plotly »
120 100 80 60 40 20 0 -20 -40 2012 2013 2014 2015 2016 2017 2018 2019 Export to plot.ly »
80 -40 -60 -80 -100 Jan 2015 Jul 2015 Jan 2016 Jul 2016 Jan 2017 Jul 2017 Jan 2018 Jul 2018 Export to plotly »
150 100 -100 -150 2014 2015 2016 • • 2017 2018 2019 Export to plotly »
80 60 40 20 0 -20 -40 Jul 2014 Jan 2015 Jul 2015 Jan 2016 Jul 2016 • • •• Jan 2017 Jul 2017 Jan 2018 Jul 2018 Export to plotly »
200 150 100 -50 2014 2015 2016 H* 2017 2018 2019 Export to plotly »
2013 2014 2015 2016 2017 2018 2019 Export to plotly »
100 -50 Jul 2014 Jan 2015 Jul 2015 Jan 2016 Jul 2016 Jan 2017 Jul 2017 Jan 2018 Jul 2018 Export to plotly »
реактор,комменты Реактора,длиннопост
Черновой пишет, рандомную строку с ошибкой с "тся" и "ться", контрольный его тролит
Черновой пишет "Алешку Анального надо пожизненно посадить", контрольный троллит его
Пару дней на калибровку и прописывание плохих/хороших сценариев и 3 месяца стать новым Вождем или Сплитом
Я думал, у тебя припадки бывают, а оказывается ты такой перманентно уже 3.5 года.
киану.жпг
Звучит так, будто ты не учил матан.
Можно поставить url http://joyreactor.cc/user/{user}/comments/{page} в адресную строку и поменяв {user} и {page} на которые вам нужно и поймёте как это работает.
Вы сами сможете что то подобное сделать. Нажмите F12 выберите консоль и вставите код в консоль.
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var a = document.createElement('div');
parser = new DOMParser();
doc = parser.parseFromString(this.responseText, "text/html");
doc = doc.getElementsByClassName('comment');
Array.from(doc).forEach(function(item) {
console.log('|-----------------');
console.log(item.innerText);
console.log('|-----------------');
});
}
};
// http://joyreactor.cc/user/{user}/comments/{page}
xhttp.open("GET", "http://joyreactor.cc/user/sandu9111/comments/1", true);
xhttp.send();
Попробуй убрать все русскоязычные комменты из скрипта, открыв .py-файл в блокноте.
но у меня почему-то отрабатывает по одной странице и выводит график. запускать вручную все свои 1119 страниц я офигею просто. есть идеи что могло пойти не так?
yData.append(float(cRate))
ValueError: could not convert string to float:
А у меня такого нет. Попробуй скачать новый скрипт и воспользоваться им.
В конце скрипт выдал вот это
Saving excel file...
done.
Traceback (most recent call last):
File "***\jr_comments_of_any_user.py", line 370, in
plotly.offline.plot([plotgo.Scatter(x=xData, y=yData, mode='markers', text=cLinks)], filename='graph.html')
File "***\AppData\Local\Programs\Python\Python37-32\lib\site-packages\plotly\graph_objs\_scatter.py", line 1987, in __init__
from plotly.validators import (scatter as v_scatter)
ImportError: cannot import name 'scatter' from 'plotly.validators' (***\AppData\Local\Programs\Python\Python37-32\lib\site-packages\plotly\validators\__init__.py)
Судя по всему, он график должен был строить.