zoukankan      html  css  js  c++  java
  • 使用TidCookieManager得到cookie

    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://de.mofeel.net/’);
    cookies:=’Cookie:’+mycookie;
    idhtp1.Request.CustomHeaders.Text:=cookies;
    4.设置HTTPOptions的hoForceEncodeParams为False,否则post的数据可能会以%20形式编码。
    5.若要使用HTTP/1.1,可将HTTPOptions的hoKeepOrigProtocol设为True,然后将ProtocolVersion设为pv1_1
  • 相关阅读:
    Networking
    Table of Contents
    Table of Contents
    Jersey(1.19.1)
    Jersey(1.19.1)
    11.Container With Most Water---两指针
    85.Maximal Rectangle---dp
    42.Trapping Rain Water---dp,stack,两指针
    84.Largest Rectangle in histogram---stack
    174.Dungeon Game---dp
  • 原文地址:https://www.cnblogs.com/bwdblogs/p/10496004.html
Copyright © 2011-2022 走看看