C
ccdarkness
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是我要做的一个搜索工具,也就是不用登录网站查看http://0daycheck.eastgame.net/0day/search.php搜索出来的软件信息,前面的都做好了,但是到下面我标记的地方有问题!!<br><br>unit TLF0DAY;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,<br> IdHTTP, StdCtrls, SUIEdit, ExtCtrls, SUIForm, SUIButton, SUIProgressBar,<br> SUIListBox, SUIMemo;<br><br>type<br> TForm1 = class(TForm)<br> IdHTTP: TIdHTTP;<br> suiForm1: TsuiForm;<br> se1: TsuiEdit;<br> sb1: TsuiButton;<br> slb: TsuiListBox;<br> sm1: TsuiMemo;<br> procedure sb1Click(Sender: TObject);<br> procedure se1KeyPress(Sender: TObject; var Key: Char);<br> procedure slbClick(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> filenfo:array of string;<br> filename:array of string;<br> addline:array of string;<br>implementation<br><br>{$R *.dfm}<br>{*大家帮看看,为什么会在这里出错!我在"tempp:=.... "这里下<br>了断点,发现程序到这里之前是没有错的,再执行下去就出现<br>“http/1.1 404 not found错误提示,但是那个网页明明存在的,也不应该是重定向问题”<br>*}<br>procedure getdown;<br>var<br>begin4,end4:integer;<br>tempp,adddown:string;<br>begin<br>tempp:=form1.IdHTTP.get('http://0daycheck.eastgame.net'+trim(form1.addline[slb.ItemIndex]));<br>begin4:=pos('TLF 0Day Public FTP Server',tempp)+26;<br>end4:=pos('</b></font><br />',tempp);<br>adddown:=copy(tempp,begin4,end4-begin4);<br>form1.sm1.Lines.Add(adddown);<br>end;<br><br><br><br>procedure getcode;<br>var<br> i, j, begin1, begin2,begin3, end1, end2,end3: integer;<br> surl, ppp, entries: string;<br> p:dword;<br>begin<br>try<br>begin<br> Form1.slb.Clear;<br> ppp := Form1.se1.Text;<br> for i := 1 to length(ppp) do<br> surl := surl + '%' + inttohex(ord(ppp), 2);<br> ppp := Form1.IdHTTP.Get('http://0daycheck.eastgame.net/0day/search.php?tlf0dayteam%5BsearchTerm%5D=' + surl);<br> //*******************************打开搜索页面,ppp保存搜索结果的页面代码************************************<br><br> begin2 := pos('totalling ', ppp) + 10;<br> end2 := pos(' entries', ppp);<br> entries := copy(ppp, begin2, end2 - begin2); //获取搜索文件的总数<br><br> setlength(addline, strtoint(entries)); //页面动态数组<br> setlength(filename, strtoint(entries)); //软件名称数组<br> setlength(filenfo, strtoint(entries));<br><br> while pos('tlf0dayteam_title', ppp) <> 0 do<br> begin<br> delete(ppp, pos('tlf0dayteam_title', ppp), 4);<br> j := j + 1;<br> end; //计算需要循环几次<br><br><br> for i := 0 to j-1 do<br> begin<br> begin1 := pos('itle"><a href="', ppp) + 15; //获取下载开始位置<br> end1 := pos('.html">', ppp); //结束下载位置<br> addline := copy(ppp, begin1, (end1 - begin1 + 5)); //得到下载页面位置<br> // Form1.slb.Items.Add(addline);<br><br>//****************************************获取软件页面地址,保存在数组addline中***************************<br><br> begin2 := pos(addline, ppp) + length(addline); //获取软件名称开始位置<br> end2 := pos('</a></h4>', ppp); // 软件名称结束位置<br> filename := copy(ppp, begin2 + 2, (end2 - begin2-2));<br> filename:=StringReplace(filename,'<br />',' | EN: | ',[rfIgnoreCase]);<br> Form1.slb.Items.Add(filename);<br><br>//***************************************获取软件名称,保存在数组filename中*******************************<br> begin3:=pos('<div class="tlf0dayteam_entry">',ppp)+31;<br> end3:=pos('<div class='+#39+'tlf0dayteam_entryFooter'+#39+'>',ppp);<br> filenfo:=copy(ppp,begin3,end3-begin3);<br> //form1.slb.Items.Add(filenfo);<br>//****************************************软件信息,保存在数组<br> end2:= pos('</a></h4>', ppp);<br> delete(ppp, end2, 7);<br> delete(ppp, begin1 - 15, 15);<br> end1 := pos('.html">', ppp);<br> delete(ppp, end1, 7);<br> end1 := pos('.html">', ppp);<br> delete(ppp, end1, 7);<br> begin3:= pos('<div class="tlf0dayteam_entry">',ppp)+31;<br> delete(ppp,begin3-31,31);<br> end3:=pos('<div class='+#39+'tlf0dayteam_entryFooter'+#39+'>',ppp);<br> delete(ppp,end3,30);<br> //Form1.sm1.Clear;<br> //Form1.sm1.Lines.Add(ppp);<br> end;<br> end;<br> finally<br> end;<br>end;<br><br><br>procedure TForm1.sb1Click(Sender: TObject);<br>var<br> id: dword;<br>begin<br> createthread(nil, 0, @getcode, nil, 0, id);<br>end;<br><br>procedure TForm1.se1KeyPress(Sender: TObject; var Key: Char);<br>begin<br> if Key = chr(13) then<br> Form1.sb1.Click;<br>end;<br><br>procedure TForm1.slbClick(Sender: TObject);<br>var<br>i:integer;<br>j:dword;<br>begin<br>sm1.Clear;<br>i:=slb.ItemIndex;<br>if pos('<br />',filenfo)<>0 then<br>begin<br>filenfo:=copy(filenfo,1,pos('<br />',filenfo)-1);<br>sm1.Lines.Add(filenfo);<br>end<br>else<br>sm1.Lines.Add(filenfo);<br>showmessage(addline);<br>createthread(nil, 0, @getdown, nil, 0, j);<br>end;<br><br><br>end.