📄 threadrecdataacc.pas
字号:
unit ThreadRecDataACC;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,StrUtils;
type
TThreadRecDataACC = class(TThread)
Function UnicodeToStr(intUnicode:integer):string;
function CommonCheckStr(URL_check:string):boolean; //检验是否存在网页
function CommonGetChar(URL_check:string;minv,maxv:integer):string; //折半算法
private
procedure UpdateThread;
published
procedure Execute; override;
public
FURL : String; //URL
min_num : integer; //最小值
max_num : integer; //最大值
complete : boolean;
sResult : string;
end;
implementation
uses
main_unit,CJdatabase_unit,define_unit;
//******************************************************************************
procedure TThreadRecDataACC.Execute;
var
ss:string;
i:integer;
count:integer;
begin
try
//sleep(1000);
complete:=false;
Form_main.Edit3.Text:=inttostr(strtoint(Form_main.Edit3.Text)+1);
ss:=CommonGetChar(FURL,min_num,max_num);
sResult:=UnicodeToStr(strtoint(ss));
complete:=true;
Synchronize(UpdateThread);
except on E:Exception do
define_unit.SaveToLogFile('c:\','TThreadRecDataACC'+E.Message);
end;
end;
//******************************************************************************
procedure TThreadRecDataACC.UpdateThread;
begin
Form_main.Edit1.Text:=inttostr(strtoint(Form_main.Edit1.Text)+1);
end;
//*****************************************************************************
Function TThreadRecDataACC.UnicodeToStr(intUnicode:integer):string;
var
wStr: WideString;
begin
try
SetLength(wStr, 1);
wStr[1]:=WideChar(intUnicode);
Result:=WidecharToString(pWideChar(wStr));
except
Result:='';
end;
end;
//******************************************************************************
function TThreadRecDataACC.CommonGetChar(URL_check:string;minv,maxv:integer):string; //折半算法
var
midv:integer;
begin
while true do
begin
Form_main.stop_column:=true;
midv:=(maxv+minv)div 2;
If CommonCheckStr(URL_Check + '>' + inttostr(midv) + form_main.URL_Check_End) Then
If MaxV - midv = 1 Then
begin
CommonGetChar:= inttostr(MaxV);
exit;
end
else
MinV:=midv+1
else
if MaxV-midv= 1 Then
begin
CommonGetChar:= inttostr(midv);
exit;
end
else
MaxV:= midv;
end;
end;
function TThreadRecDataACC.CommonCheckStr(URL_check:string):boolean; //检验是否存在网页
var
i:integer;
content:string;
label start;
begin
Form_main.stop_column:=true;
if CJdatabase_unit.Inject_methord=1 then
begin
if Form_main.CheckBox_keyword.Checked=true then
begin
content:=define_unit.GetURLContent(URL_check);
if pos(trim(Form_main.Edit_keyword.Text),content)>0 then
result:=true
else
result:=false;
end
else
begin
start:
i:= define_unit.GetURLCode(URL_check) ;
if i=200 then
CommonCheckStr:=true
else
begin
if i=500 then
CommonCheckStr:=false
else goto start;
end;
end;
end; //end of CJdatabase_unit.Inject_methord
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -