I am looking on trying to create a simple program that would allow the user to enter text into a field. the program would then take that word and post it to a form. the server would take that and submit it back with the results. once the program has the results it would display the links within the program and allow the user to download/open up the webpage/file within the program and would not use wininet to do this. if anybody can post source code that might be able to first take a TEdit field post it to a known form (this is the webpage).
<!-- HEADER -->
<form action="
http://www.filemirrors.com/search.src"
method=post id=form1 name=form1>
<table width=100% cellmargin=0 cellpadding=0 cellspacing=0 border=0>
<TR><TD bgcolor="#CCCCCC" valign=top align=left background="images-fm/head
erbg.gif">
<a href="/"><img src="images-fm/header1.gif
" width=226 height=69 border=0 alt="FileMirrors"></a></TD
>
<TD bgcolor="#CCCCCC" valign=bottom align=right background="images-fm/head
erbg.gif">
<table cellmargin=0 cellpadding=0 cellspacing=0 border=0>
<TR>
<TD valign="bottom" bgcolor="#CCCCCC" valign=bottom background="images-fm/head
erbg.gif" nowrap>
<center>
<font face="Verdana,Arial,helvet
ica,sans-s
erif" size="-2"><b>File Name</b><br>
<select name=type>
<option value="contains">contains
<option value="equals">equals
<option selected value="begins">begins with
<option value="ends">ends with
</select>
</font></center>
</td>
<TD valign="bottom" bgcolor="#CCCCCC" valign=bottom background="images-fm/head
erbg.gif" nowrap>
<input name="file" size=14 value="" maxlength=30>
</td>
<TD colspan=3 valign="bottom" bgcolor="#CCCCCC" valign=bottom background="images-fm/head
erbg.gif" nowrap>
<input type="submit" name="action" value="Find">
</TD>
and would submit and then retrieve and show in the program as a datafield with within the program then I would be most thanks full.
If you give me something that works and works great then I will add another 200 points(if you wait a bit).
thanks alot.
the source code for the program I am working on is this
unit WebFindF;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, ExtCtrls;
type
TForm1 = class(TForm)
BtnFind: TButton;
EditSearch: TEdit;
StatusBar1: TStatusBar;
Label1: TLabel;
Memo2: TMemo;
Panel1: TPanel;
Splitter1: TSplitter;
ListBox1: TListBox;
procedure BtnFindClick(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
DetailsList: TStrings;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
uses
FindTh;
const
strSearch = '
http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=';
procedure TForm1.BtnFindClick(Sender
: TObject);
var
FindThread: TFindWebThread;
begin
// create suspended, set initial values, and start
FindThread := TFindWebThread.Create (True);
FindThread.FreeOnTerminate
:= True;
FindThread.strUrl := strSearch + EditSearch.Text +
'&num=100'; // grab the first 100 entries
FindThread.Resume;
end;
procedure TForm1.ListBox1Click(Sende
r: TObject);
begin
Memo2.Text := DetailsList [ListBox1.ItemIndex];
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DetailsList := TStringList.Create;
end;
procedure TForm1.FormDestroy(Sender:
TObject);
begin
DetailsList.Free;
end;
end.
unit FindTh;
interface
uses
Classes, IdComponent, SysUtils, IdHTTP;
type
TFindWebThread = class(TThread)
protected
Addr, Text, Status: string;
procedure Execute; override;
procedure AddToList;
procedure ShowStatus;
procedure GrabHtml;
procedure HtmlToList;
procedure HttpWork (Sender: TObject;
AWorkMode: TWorkMode; const AWorkCount: Integer);
public
strUrl: string;
strRead: string;
end;
implementation
{ TFindWebThread }
uses
WebFindF;
procedure TFindWebThread.AddToList;
begin
if Form1.ListBox1.Items.Index
Of (Addr) < 0 then
begin
Form1.ListBox1.Items.Add (Addr);
Form1.DetailsList.Add (Text);
end;
end;
procedure TFindWebThread.Execute;
begin
GrabHtml;
HtmlToList;
Status := 'Done with ' + StrUrl;
Synchronize (ShowStatus);
end;
procedure TFindWebThread.GrabHtml;
var
Http1: TIdHTTP;
begin
Status := 'Sending query: ' + StrUrl;
Synchronize (ShowStatus);
Http1 := TIdHTTP.Create (nil);
try
Http1.OnWork := HttpWork;
strRead := Http1.Get (StrUrl);
finally
Http1.Free;
end;
end;
procedure TFindWebThread.HtmlToList;
var
strAddr, strText: string;
nText: integer;
nBegin, nEnd: Integer;
begin
Status := 'Elaborating data for: ' + StrUrl;
Synchronize (ShowStatus);
strRead := LowerCase (strRead);
repeat
// find the initial part HTTP reference
nBegin := Pos ('href=http', strRead);
if nBegin <> 0 then
begin
// get the remaining part of the string, starting with 'http'
strRead := Copy (strRead, nBegin + 5, 1000000);
// find the end of the HTTP reference
nEnd := Pos ('>', strRead);
strAddr := Copy (strRead, 1, nEnd - 1);
// move on
strRead := Copy (strRead, nEnd + 1, 1000000);
// add the URL if 'google' is not in it
if Pos ('google', strAddr) = 0 then
begin
nText := Pos ('</a>', strRead);
strText := copy (strRead, 1, nText - 1);
// remove cached references and duplicates
if (Pos ('cached', strText) = 0) then
begin
Addr := strAddr;
Text := strText;
AddToList;
end;
end;
end;
until nBegin = 0;
end;
procedure TFindWebThread.HttpWork(Se
nder: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
Status := 'Received ' + IntToStr (AWorkCount) + ' for ' + strUrl;
Synchronize (ShowStatus);
end;
procedure TFindWebThread.ShowStatus;
begin
Form1.StatusBar1.SimpleTex
t := Status;
end;
end.
first I cant get it to post or even show what it has gotten when it searches the webpage(even with get) and I have no idea how to post.
I will start this out with 50 points since I have a allmost working source code and if I get a good response I will up it to the max that I can(if in a day 30 points) and if you answer me within a day and it works without a problem I will up another 100 points as soon as I get them.