請問如何模擬在網頁上填資料送出的動作阿.. |
尚未結案
|
liang-shien
一般會員 發表:15 回覆:21 積分:7 註冊:2005-05-26 發送簡訊給我 |
|
supman
尊榮會員 發表:29 回覆:770 積分:924 註冊:2002-04-22 發送簡訊給我 |
您好:
以下有許多範例,參考看看.
http://delphi.ktop.com.tw/topic.php?topic_id=21505
http://delphi.ktop.com.tw/topic.php?topic_id=30154
http://delphi.ktop.com.tw/topic.php?topic_id=28813
http://delphi.ktop.com.tw/topic.php?topic_id=28873
http://delphi.ktop.com.tw/topic.php?topic_id=42261
http://delphi.ktop.com.tw/topic.php?topic_id=47975
http://delphi.ktop.com.tw/topic.php?topic_id=18695
http://delphi.ktop.com.tw/topic.php?topic_id=47086 發表人 - supman 於 2005/05/31 13:59:10
|
liang-shien
一般會員 發表:15 回覆:21 積分:7 註冊:2005-05-26 發送簡訊給我 |
|
alanktop
一般會員 發表:7 回覆:21 積分:5 註冊:2005-03-01 發送簡訊給我 |
可以安装WSockExpert这个软件,然后你可以启动它,并点击网页上的按钮,可以捕捉到该按钮作了什么样的Post动作。于是在程序中也使用Post方法送出这些数据即可完全达到效果。
请看下面的例子:
http://www.tdcenterprise.com/cgi-bin/hkei.dll/Jsp/hkei/g_search_result_r.jsp
在Search栏里输入“CD Player”,点击“go”按钮 被捕获到的数据如下:
POST /cgi-bin/hkei.dll/Jsp/hkei/g_search_result_r.jsp HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://www.tdcenterprise.com/cgi-bin/hkei.dll/Jsp/hkei/g_search_result_r.jsp
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
Host: www.tdcenterprise.com
Content-Length: 100
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: BV_IDS=ccchadddkkkglgecgegcfhedglidfji.0:@@@@0306527526.1108449904@@@@; browserID=browserID=37A0B0D672D2 haveInput=true&ChangeFlag=yes&query=CD Player&target=pca&Region=ALL&Region=ALL&image.x=17&image.y=11 真正有用的就是上面这段数据:
haveInput=true&ChangeFlag=yes&query=CD Player&target=pca&Region=ALL&Region=ALL&image.x=17&image.y=11 代码如下: PostData := VarArrayCreate([0, Length(Form1.readjava) - 1], varByte);
Data := VarArrayLock(PostData);
try
Move(Form1.readjava[1], Data^, Length(Form1.readjava));
finally
VarArrayUnlock(PostData);
end;
URL := Form1.readbuttonfield;
Flags := EmptyParam;
TargetFrameName := EmptyParam;
Headers := EmptyParam; // TWebBrowser will see that we are providing
// post data and then should automatically fill
// this Headers with appropriate value
Form1.WebBrowser1.Navigate2(URL, Flags, TargetFrameName, PostData, Headers); 在这里,变量URL即:http://www.tdcenterprise.com/cgi-bin/hkei.dll/Jsp/hkei/g_search_result_r.jsp
PostData即:haveInput=true&ChangeFlag=yes&query=CD Player&target=pca&Region=ALL&Region=ALL&image.x=17&image.y=11
|
paste
一般會員 發表:13 回覆:19 積分:6 註冊:2005-04-27 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |