看了你的问题,我的问题:
1。你是说纯HTML,还是其他方式:即想提交到那里去
2。或是说在WEBBROWSER中找到目标提交?
3。其他
如果是2,使用NMHTTP控件即可实现,
aa:='http://www.086net.com/dd.asp?';
cc:='name=jasonet&password=jasonet';
nmhttp1.post(aa,cc);
...
1。你是说纯HTML,还是其他方式:即想提交到那里去
2。或是说在WEBBROWSER中找到目标提交?
3。其他
如果是2,使用NMHTTP控件即可实现,
aa:='http://www.086net.com/dd.asp?';
cc:='name=jasonet&password=jasonet';
nmhttp1.post(aa,cc);
...
演示代码如下:
(1).将传送的数据写在tmp.txt中;
格式:name=csdn&url=csdn.net&password=1232&helpid=id1234..........
(2).Delphi实现代码:
NMHTTP1.InputFileMode:=False;
NMHTTP1.OutputFileMode:=True; //此属性必须为True
NMHTTP1.ReportLevel:=Status_Basic;
NMHTTP1.Post('http://127.0.0.1/test.asp','tmp.txt');本来Post(...,'user=abc&password=def')
我发送出去的content中的内容就必须是user=abc&password=def
可是nmhttp自作聪明URLEncode了一把,把发送的内容变成了
user%3Dabc%26password%3Ddef
(就是说,把等号(=) encode 为 %3d ,把&变成 %26,画蛇添足)推荐ics控件了:
http://www.rtfm.be/fpiette/indexuk.htm 免费软件、带源码。
post写起来麻烦一点,不过是有用的:TMemoryStream* sendstr=new TMemoryStream();
TMemoryStream* rcvdstr=new TMemoryStream();
char buf[]="user=abc&password=xyz";
sendstr->Write(buf,sizeof(buf)-1);//减一是不要最后的\0字符
sendstr->Position=0;
h->RcvdStream=rcvdstr;
h->SendStream=sendstr;
h->URL="http://127.0.0.1/test.asp";
h->Post();
ShowMessage(AnsiString((char*)rcvdstr->Memory,rcvdstr->Size));
o : Olevariant;
Begin
o := wb_Cash.OleObject.document.all.item('LoginName',0);//找到相应的EDIT
o.value := '1122'; //填写
o := wb_Cash.oleobject.document.all.item('Password',0);
o.value := 'sdfs';
wb_Cash.oleobject.document.Forms.Item(0, 0).submit;//用第一个提交
Dim l As Long
Dim l1 As Long
Dim zoo As IHTMLTxtRange
Private Sub Command1_Click()
WB.Navigate "D:\download\formsamp002.mht"
'WB.Navigate "D:\diaocha.htm"
End SubPrivate Sub Command2_Click()
Dim astr As String
Dim zo As IHTMLTxtRange
'Debug.Print WB.Document.selection
Set zo = WB.Document.selection.createRange
'zo.get_htmlText astr
Debug.Print zo.Text
zo.findText "Internet"
End SubPrivate Sub Command3_Click()
Dim zo As IHTMLTxtRange
Dim x1 As Variant
'If zoo <> Null Then
zoo.findText "Internet"
zoo.Select
x1 = zoo.Move("Textedit")
Debug.Print x1
'x1 = "internet"
'WB.ExecWB OLECMDID_FIND, OLECMDEXECOPT_DODEFAULT, x1, x2
'Set zo = WB.Document.selection.createRange
'Debug.Print zo.Text
'xx = ""
'zoo.setEndPoint xx, zo
'End If
End SubPrivate Sub WB_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
Set zoo = Nothing
End SubPrivate Sub WB_DownloadComplete()
Set zoo = WB.Document.body.createTextRange
End SubPrivate Sub WB_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Dim i, j
Dim xo, yo
'
' Set zoo = WB.Document.body.createTextRange
List1.Clear
List2.Clear
For i = 0 To WB.Document.All.length - 1
List1.AddItem WB.Document.All(i).tagName
If WB.Document.All(i).tagName = "INPUT" Then
Set xo = WB.Document.All(i)
'List2.AddItem xo.Type
If xo.Type = "text" Then
Debug.Print xo.Size
'List2.AddItem "text"
'xo.focus
'xo.setAttribute "", "OKOK"
xo.Value = "OKOK"
End If
'List2.AddItem xo.Style
' List2.AddItem xo.className
' List2.AddItem xo.Title
List2.AddItem xo.Name
End If
If WB.Document.All(i).tagName = "TEXTAREA" Then
Set xo = WB.Document.All(i)
xo.Value = "Textarea"
End If
' If WB.Document.All(i).tagName = "SELECT" Then
' Set yo = WB.Document.All(i)
' For j = 0 To yo.All.length - 1
' List2.AddItem yo.All(j).Text
' Next j
' yo.selectedIndex = 6 'yo.All(5).Text
' End If
Next i
End Sub
上面的代码并不是直接点击发送的,你需要分析并改一下。http://www.applevb.com
前些日子,有朋友要我帮忙做一这样的程序,其目的是方便在网上赚钱!
^_*
小弟是在校学生!我相信大家聚在这里的主要原因也是共同探讨,共同进步。我个人认为中国的软件业落后于印度的一个原因是中国人不善于交流且相互猜忌!
oh!我忘了提醒您,您的系统时间好象出差了!好象快了不少啊!!!
我倒!大虾你先别忙自己的,先帮兄弟一把好不好!