How to parse HttpWebResponse.Headers.Keys for a Set-Cookie session id returned

后端 未结 4 574
名媛妹妹
名媛妹妹 2020-12-13 07:46

I\'m trying to create an HttpWebRequest/HttpWebResponse session with an ASP.NET website to later parse an HTML form through url params (this part I know how to do), but I do

4条回答
  •  醉酒成梦
    2020-12-13 08:09

    I have the same problem (with amazon) I use the following regexp:

    string regexp = "(?[^=]+)=(?[^;]+)[^,]+,?";);
    MatchCollection myMatchCollection = Regex.Matches(cookiesStr, regexp);
    foreach (Match myMatch in myMatchCollection)
    {
    string cookieName = myMatch.Groups["name"].ToString();
    string cookieVal = myMatch.Groups["val"].ToString();
    Cookie cookie = new Cookie(cookieName, cookieVal);
    cookies.Add(cookie);
    }

    Note that I only care about the cookie name/value...

    good luck Elia

提交回复
热议问题