Advertisement
Guest User

2ch Parser

a guest
Mar 8th, 2017
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 3.74 KB | None | 0 0
  1. unit Unit2;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.OleCtrls, SHDocVw,
  8.   Vcl.ExtCtrls, Soap.InvokeRegistry, IdBaseComponent, IdComponent,
  9.   IdTCPConnection, IdTCPClient, IdHTTP, Soap.Rio, Soap.SOAPHTTPClient;
  10.  
  11. type
  12.   TForm2 = class(TForm)
  13.     Button1: TButton;
  14.     Edit1: TEdit;
  15.     Panel1: TPanel;
  16.     OpenDialog1: TOpenDialog;
  17.     Memo1: TMemo;
  18.     Button2: TButton;
  19.     Memo2: TMemo;
  20.     WebBrowser1: TWebBrowser;
  21.     ListBox1: TListBox;
  22.     CheckBox1: TCheckBox;
  23.     CheckBox2: TCheckBox;
  24.     procedure Button1Click(Sender: TObject);
  25.     procedure Edit1Click(Sender: TObject);
  26.     procedure Button2Click(Sender: TObject);
  27.     procedure FormCreate(Sender: TObject);
  28.   private public end;
  29. var Form2: TForm2; a,b,c,j:string; e:textfile;
  30. implementation {$R *.dfm}
  31. procedure TForm2.Button1Click(Sender: TObject);var i,h:integer; begin
  32.   a:=Edit1.Text; b:='';
  33.   for  i:=1 to length(a) do begin
  34.     if a[i]='.' then
  35.       h:=i-1;
  36.   end;
  37.   for i:=1 to h do
  38.     b:=b+a[i];
  39.   b:=b+'.json';
  40.   WebBrowser1.Navigate(b);
  41. end;
  42.  
  43. procedure TForm2.Button2Click(Sender: TObject); var str:string; tsl:TStringList; i,k,posI,g,oo:integer;
  44.  lin,endl:string; formats:boolean; begin
  45.   Memo2.Clear;
  46.   OpenDialog1.Execute();
  47.   AssignFile(e, OpenDialog1.FileName); Reset(e);
  48.   Memo1.lines.LoadFromFile(OpenDialog1.FileName); CloseFile(e);
  49.   str:='path'; tsl:=TStringList.Create;
  50.   tsl.DelimitedText:=Memo1.Text;
  51.   k:=0;
  52.   Memo2.Lines.Add('<html><head><title>2ch</title></head><style>');
  53.   Memo2.Lines.Add('* {font-family: verdana; color: #000; Verdana; padding: 0; margin: 0; overflow-x:hidden;}');
  54.   Memo2.Lines.Add('a {color: #fff; text-decoration: none; border-radius: 5px; background-color: #55cc62;}');
  55.   Memo2.Lines.Add('#content {margin: 48px auto 10px; min-width: 100px; max-width: 600px;}');
  56.   Memo2.Lines.Add('img {margin: 10px auto 10px; min-width: 100px; max-width: 600px;}');
  57.   Memo2.Lines.Add('video {margin: 10px auto 10px; min-width: 100px; max-width: 600px;}');
  58.   Memo2.Lines.Add('#inform {position: fixed; margin: 0 0 10px;padding: 20px;background-color: #e8e8e8; width: 100%;');
  59.   Memo2.Lines.Add('</style><body><div id="inform"><center>@Вот что нам удалось найти:</div><div id="content"><center>');
  60.  
  61.   for i:=1 to tsl.Count-1 do begin
  62.     if tsl[i]=str then begin
  63.       inc(k); posI:=1;
  64.     end;
  65.     if (posI=1) then begin
  66.       if tsl[i]<>str then begin
  67.         ListBox1.items.add(tsl[i]); posI:=0;
  68.         ListBox1.ItemIndex:=ListBox1.Items.Count-1;
  69.       end;
  70.     end;
  71.   end;
  72.   for i:=0 to ListBox1.Items.Count-1 do begin
  73.     lin:=(ListBox1.Items[i]);
  74.     endl:='';
  75.     for g:=3 to length(lin)-1 do begin
  76.       endl:=endl+(lin[g]);
  77.     end;
  78.     for oo:=0 to length(endl) do begin
  79.       if endl[oo]='w' then formats:=true;
  80.     end;
  81.     if formats=true then if CheckBox1.Checked=true then Memo2.Lines.Add('<div><video id="movies" onmouseover="this.play()" onmouseout="this.pause()" loop="" controls=""><source src="https://2ch.hk'+endl+'" type="video/webm"></video><br>.webm <a href="https://2ch.hk'+endl+'">оригинал</a></div>');
  82.     if formats=false then if CheckBox2.Checked=true then Memo2.Lines.Add('<div><img src="https://2ch.hk'+endl+'"><br>.img <a href="https://2ch.hk'+endl+'">оригинал</a></div>');
  83.     formats:=false;
  84.   end;
  85.   Memo2.Lines.Add('</center></div></body></html>');
  86.   Memo2.Lines.SaveToFile(OpenDialog1.FileName+'.html');
  87. end;
  88.  
  89. procedure TForm2.Edit1Click(Sender: TObject); begin
  90.   Edit1.SelectAll; end;
  91. procedure TForm2.FormCreate(Sender: TObject);
  92. begin
  93. Application.Title:='2chContent PARSER';
  94. ShowMessage('https://gigeu.url.ph');
  95. end;
  96.  
  97. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement