delphi使用IdHTTP模擬提交頁面方法總結

2021-07-11 17:01:35 字數 867 閱讀 4635

1.拖入tidhttp控制項,handleredirect設為true,否則可能會出現http 307錯誤。

2.主要的設定在request裡。

2.1 useragent應該改為mozilla/4.0 (compatible; msie 7.0; windows nt 5.1; .net clr 2.0.50727; .net clr 3.0.04506.30; ciba; maxthon 2.0)

2.2 如果accept-encoding設為了gzip, deflate,那麼需要再解碼,所以如果沒有必要的話accept-encoding應該設為空。

2.3 referer應該設為post之前那個頁面.

3.若需要取得cookie。

3.1 拖入tidcookiemanager控制項,將idhttp的cookiemanager指向它,設定allowcookies為true

3.2 設定全域性變數mycookie:string;

3.3 在tidcookiemanager的onnewcookie事件中

mycookie:=acookie.clientcookie;

3.4 然後在用tidhttp控制項get頁面後即可獲取cookie

idhtp1.get('');

cookies:='cookie:'+mycookie;

idhtp1.request.customheaders.text:=cookies;

4.設定httpoptions的hoforceencodeparams為false,否則post的資料可能會以%20形式編碼。

5.若要使用http/1.1,可將httpoptions的hokeeporigprotocol設為true,然後將protocolversion設為pv1_1。

delphi使用IdHTTP模擬提交頁面方法總結

1.拖入tidhttp控制項,handleredirect設為true,否則可能會出現http 307錯誤。2.主要的設定在request裡。2.1 useragent應該改為mozilla 4.0 compatible msie 7.0 windows nt 5.1 net clr 2.0.507...

Delphi用IdHTTP提交自定義Cookie

get的方式如下 procedure get aurl string const aresponsecontent tstream overload function get aurl string string overload 引數和post方式型別,但是沒有第二個引數。下面是idhttp的相關...

使用控制項IdHttp遇到的奇怪現象

今天為了實現論壇自動登入發貼,作了如下嘗試 asp 說明 登入頁面為 login.asp 要提交的表單兩個 txt user,txt password 登入後提交的頁面是 login check.asp,該頁面我的測試 簡單的只有以下 username trim request.form txt u...