Помоги те мне. Есть код. Программа должна открывать страницы нужного мне сайта и при открытии одной страницы, переходить на следующую. Страница открывается, но на следующую не переходит. В чем ошибка?
Код:
#apptype windows
#reference 'System.Windows.Forms.dll'
#reference 'System.Drawing.dll'
uses System.Windows.Forms;
var MyForm: Form; web1: WebBrowser; urls: array of string; i: integer;
procedure ReadInfo(sender: object; args: System.Windows.Forms.WebBrowserDocumentCompletedEventArgs);
var s: string;
begin
var f := new System.IO.StreamWriter(application.StartupPath+'\Temp.txt');
f.Write(web1.DocumentText);
f.Close;
var f2 := new System.IO.StreamReader(application.StartupPath+'\Temp.txt');
s:= f2.ReadToEnd;
f2.Close;
var startindex:=pos('price_num',s);
var endindex:=pos('span',s);
var str:=copy(s,startindex+11,endindex-startindex-11);
var st:=StrToInt(str);
MessageBox.Show(st);
inc(i); //здесь увеличиваем i
web1.Url:= new System.Uri(urls[i]); //и вызываем тоже с индексом i
web1.ResetBackColor;
end;
begin
MyForm:= new Form;
web1:= new WebBrowser;
web1.Dock:= dockstyle.Fill;
web1.DocumentCompleted+= ReadInfo;
SetLength(urls,1000000);
for i:= 0 to 100000 do //здесь считаем с помощью i
urls[i]:= 'http://www.example.com/user?id='+IntToStr(100000+i);
//и индекс здесь тоже должен быть i, и прибавляем к 100000 тоже i, чтобы элементы разными были
MyForm.Controls.Add(web1);
web1.Url:= new System.Uri(urls[0]); //здесь 0 должен быть, так как переходит на первую страницу
web1.ResetBackColor;
Application.Run(myForm);
end.