试一下MSHTML吧,里面有对HTML的封装,即使把网页的所有元素都当成对象来使用,比如你要给网页上的输入框赋值,可以用IHTMLInputElement(好像是这个,呵呵……),找到它,给它赋值即可。给你一点思路吧:
var
i, j, len: integer;
elec: IHTMLElementCollection;
doc: ihtmldocument2;
chele: IHTMLElement;
InputElement: IHTMLInputElement;
TextAreaElement: IHTMLTextAreaElement;
FormElement: IHTMLFormElement;
FormCollection: IHTMLElementCollection;
Element1: IHTMLElement;
SelectElement: IHTMLSelectElement;
begin
doc := webbrowser1.document as IHtmlDocument2;
elec := doc.all;//取得网页所有元素
for i := 0 to elec.length - 1 do
begin
chele := elec.item(i, emptyparam) as IHTMLElement;
if chele.tagname = 'INPUT' then//找到输入框
try
InputElement := elec.item(i, emptyparam) as IHTMLInputElement;
if InputElement.name = cv_send[cv_currweb] then//这里找到你要的输入框
InputElement.value := self.edit2.text;//给输入框赋值
except
end;
if chele.tagname = 'TEXTAREA' then
begin
try
TextAreaElement := elec.item(i, emptyparam) as
IHTMLTextAreaElement;
if TextAreaElement.name = cv_content[cv_currweb] then
TextAreaElement.value := self.memo1.Lines.text;
except
end;
end;
end;
for i := 0 to elec.length - 1 do
begin
chele := elec.item(i, emptyparam) as IHTMLElement;
if cv_form[cv_currweb] <> '' then
if chele.tagname = 'FORM' then
begin
try
FormElement := elec.item(i, emptyparam) as
IHTMLFormElement;
if FormElement.name = cv_form[cv_currweb] then
begin
FormElement.submit;
end;
except
end;
end;
end;
end;
代码是粘过来的,可能有点不对,你试试看吧!