- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
procedure TMonThread.FillCommentList;
var
HTTP:TIdHTTP;
URI:TIdURI;
S, Temp, Link, LastCm:string;
I, J:Integer;
Comm:TGComment;
Post:TGpost;
LinkList:TstringList;
CommList:TStringList;
begin
LinkList:=TStringList.Create;
CommList:=TStringList.Create;
HTTP:=TIdHTTP.Create(nil);
URI:=TIdURI.Create();
try
Temp:='';
LinkList.Sorted:=True;
LinkList.Duplicates:=DupIgnore;
HTTP.UserAgent:=uaRandom;
URI.Host:='govnokod.ru';
HTTP.Request.Host:='govnokod.ru';
HTTP.CookieManager.AddServerCookie('auth=a7dbe7abed9025a9a13ea15baa89a08f',URI);
Temp:=HTTP.LoadContent('http://govnokod.ru/comments');
Temp:=StringReplace(Temp,#13#10,'',[rfreplaceall]);
Temp:=StringReplace(Temp,#13,'',[rfreplaceall]);
Temp:=StringReplace(Temp,#10,'',[rfreplaceall]);
ParseAll('<li class="hentry">',Temp,'<div class="show-code">', LinkList);
for J:=0 to LinkList.Count-1 do
begin
if FCanceled then Exit;
Link:=ParseStr('<h2>Комментарий к <a rel="bookmark" class="entry-title" href="',LinkList[J],'"');
HTTP.ConnectTimeout:=60000;
HTTP.ReadTimeout:=60000;
Temp:='';
Temp:=HTTP.LoadContent(Link);
if HTTP.ContentSize>2000000 then Continue;
if HTTP.ResponseCode <> 200 then Continue;
if Pos('halted by an exception', Temp)>0 then Exit;
Post:=TGPost.Create;
LastCm:=Trim(ParseStr('name="comment', LinkList[J],'"'));
Post.LastCommentId:=StrToInt(LastCm);
S:=ParseStr('<a rel="bookmark" class="entry-title" href="http://govnokod.ru/', Temp,'"');
Post.Number:=StrToInt(S);
Post.Link:='http://govnokod.ru/'+S+'/';
S:=ParseStr('<p class="author">',Temp,'</p>');
S:=ParseStr('</a> <a href="http://govnokod.ru/user/',S,'</');
Post.Author:=StrAfter('>',S);
FPosts.Add(Post);
CommList.Clear;
ParseAll('<div id="comment-',Temp, '</li>', CommList);
for I:=0 to CommList.Count-1 do
begin
if FCanceled then Exit;
Comm:=TGComment.Create;
Comm.Author:=ParseStr('<strong class="entry-author"><a href="http://govnokod.ru/user/',CommList[I],'</strong>');
Comm.Author:=ParseStr('">', Comm.Author,'<');
Comm.Text:=ParseStr('<span class="comment-text">',CommList[I],'</span></div>');
Comm.Text:=DecorateText(Comm.Text);
//comment is hidded?
Comm.Hidden:=Pos('<span class="hidden-text">',CommList[I])>0;
// parse and calculate rating values.
Temp:=ParseStr('<span class="comment-vote">', CommList[I],'</span>');
//on count
S:=Trim(StrAfter('title="',Temp));
S:=Trim(StrBefore(' ',S));
Comm.OnCount:=StrToInt(S);
//against count
S:=Trim(StrAfter('и ',Temp));
S:=Trim(StrBefore(' ',S));
Comm.AgainstCount:=StrToInt(S);
Comm.Rating:=Comm.OnCount-Comm.AgainstCount;
S:=ParseStr('class="comment-vote-against" href="http://govnokod.ru/ratings/comment/',Temp,'/');
S:=Format('http://govnokod.ru/ratings/comment/%s/against',[S]);
Comm.AgainstLink:=S;
S:=ParseStr('<a class="answer" href="http://govnokod.ru/comments/', CommList[I],'"');
S:='http://govnokod.ru/comments/'+S;
Comm.AnswerLink:=S;
LastCM:=IntToStr(Post.LastCommentId);
Comm.Last:=Pos(LastCm, Comm.AnswerLink)>0;
Post.Comments.AddObject(Comm.Text, Comm);
end;
end;
finally
CommList.Free;
LinkList.Free;
HTTP.Free;
URI.Free;
end;
end;
(Флудоминусатор) Подгрузка и обработка комментариев из стока.
DOKTOP_CMErMA 27.04.2023 23:52 # 0
AnimeGovno 29.04.2023 21:26 # −3
В Мск такого с руками оторвут.
Подайся в мск и не майся хуйнёй!
DOKTOP_CMErMA 05.05.2023 00:39 # 0