?? unit1.pas
字號:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP, OleCtrls, SHDocVw,MSHTML, ExtCtrls, DB, ADODB,
ComCtrls;
type
TForm1 = class(TForm)
IdHTTP1: TIdHTTP;
Button1: TButton;
Memo1: TMemo;
Memo2: TMemo;
Timer1: TTimer;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
Label3: TLabel;
ProgressBar1: TProgressBar;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
myi,myii:integer;
word,flag:string;
implementation
{$R *.dfm}
function GetStr(StrSource,StrBegin,StrEnd:string):string;
var
in_star,in_end:integer;
begin
in_star:=AnsiPos(strbegin,strsource)+length(strbegin);
in_end:=AnsiPos(strend,strsource);
result:=copy(strsource,in_star,in_end-in_star);
sleep(100)
end;
procedure TForm1.Button1Click(Sender: TObject);
var
strsource:string;
i:integer ;
FHTTPClient:TIdHTTP;
mybuff:string;
sql,buff,buf:string;
begin
while adoquery2.FieldByName('翻譯').AsString<>'' do
begin
adoquery2.Next;
myii:=myii+1;
end;
memo2.Text :=inttostr( myii);
if (myii<form1.adoquery2.RecordCount) then
begin
myii:=myii+1;
word:= adoquery2.FieldByName('單詞').AsString ;
adoquery2.Next;
memo1.Text:=memo1.Text+word+#13#10;
ProgressBar1.StepIt;
end;
{
//下載
FHTTPClient := TIdHTTP.Create( Self );
with FHTTPClient do
begin
Disconnect;
Request.Pragma := 'no-cache ';
Request.CacheControl := 'no-cache ';
Request.Connection := 'close';
ReadTimeout := 1000 * 20 * 1;//1分鐘超時
mybuff :=idhttp1.get('http://baidu.netat.net/trans.php?sen='+word+'&lang=encn');
end;
freeandnil(FHTTPClient); // 下載
buff:=getstr(mybuff,'<div style="width:100%;height:200px;" id="result">','以上結果由') ;
buff:=copy(buff,0,pos('<',buff)-1);
buf:=getstr(mybuff,'<textarea name="sen" rows="6" id="source">','</textarea></td>') ;
sleep(100);
sql:='update lib set 翻譯='+#39+buff+#39+' where 單詞='+#39+buf+#39;
form1.adoquery1.Close;
form1.adoquery1.SQL.Clear;
try
form1.adoquery1.SQL.Add(sql);
form1.adoquery1.ExecSQL
except
end; }
end;
procedure TForm1.FormCreate(Sender: TObject);
var
sql,st:string;
begin
myi:=1;
myii:=0;
//flag:='start';
flag:='stop';
st:=ExtractFilePath(Application.ExeName);
adoquery1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+st+'english.mdb;Persist Security Info=False';
adoquery2.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+st+'english.mdb;Persist Security Info=False';
form1.adoquery2.Close;
form1.adoquery2.SQL.Clear;
sql:='select * from lib order by 單詞';
form1.adoquery2.SQL.Add(sql);
form1.adoquery2.Open ;
label3.Caption:='一共有'+ inttostr(form1.adoquery2.RecordCount)+'條記錄!';
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
button1.Click;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -