delphi使用IdHTTP模拟提交页面方法总结
来源:互联网 发布:天猫宝贝淘宝搜不到 编辑:程序博客网 时间:2024/06/05 03:21
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('http://www.XXX.com/');
cookies:='Cookie:'+mycookie;
idhtp1.Request.CustomHeaders.Text:=cookies;
4.设置HTTPOptions的hoForceEncodeParams为False,否则post的数据可能会以%20形式编码。
5.若要使用HTTP/1.1,可将HTTPOptions的hoKeepOrigProtocol设为True,然后将ProtocolVersion设为pv1_1。
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('http://www.XXX.com/');
cookies:='Cookie:'+mycookie;
idhtp1.Request.CustomHeaders.Text:=cookies;
4.设置HTTPOptions的hoForceEncodeParams为False,否则post的数据可能会以%20形式编码。
5.若要使用HTTP/1.1,可将HTTPOptions的hoKeepOrigProtocol设为True,然后将ProtocolVersion设为pv1_1。
0 0
- delphi使用IdHTTP模拟提交页面方法总结
- delphi使用IdHTTP模拟提交页面方法总结
- delphi使用IdHTTP模拟提交页面方法
- delphi idhttp使用
- [delphi]indy idhttp post方法
- [delphi]indy10 idhttp get方法
- [delphi]indy10 idhttp get方法
- [delphi]indy10 idhttp get方法
- Delphi Idhttp的post方法
- Delphi用IdHTTP提交自定义Cookie
- DELPHI使用IDHTTP操作WEB
- Idhttp Post 模拟提交验证码
- Delphi Idhttp的 Get 和 Post 方法
- Delphi Idhttp的get和post方法
- Delphi使用IdHttp 获取 HttpsURL内容
- DELPHI使用IDHTTP显示网络图片
- Idhttp.post 模拟向网页服务器提交信息
- 页面防重复提交方法总结
- Maven学习2之使用archetype快速生成一个新项目
- NodeJS学习笔记之FS文件模块
- 机器学习
- Android 关机流程 从kernel到framework
- 开源中国app说什么 旁边的那个图标是什么drawable
- delphi使用IdHTTP模拟提交页面方法总结
- Android之SurfaceView
- object-c方法
- MyBatis 一级缓存实现
- Redis3.0事务篇
- 如何写出优美的 C 代码
- Spring 使用注解方式进行事务管理
- Java多态性理解
- linux常用命令