我想做个网页游戏的辅助工具,现在碰到一个问题,A页面有个Iframe B页面,我要取的东西存在B页面,但这个B页需要Cookie才能访问,请问有什么好的方法取得B页面的Cookie?A 和B页是不同的domain。

解决方案 »

  1.   

    cookie 一般不都用js?
      

  2.   

    我现在用Httpwebrequest去弄,应该怎么取?
      

  3.   

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.xxx.com");
    request.Method = "GET";
    CookieContainer cc=new CookieContainer();
    request.CookieContainer = cc;//添加请求的cookies
    HttpWebResponse response = request.GetResponse() as HttpWebResponse;CookieCollection c= response.Cookies;//获取返回的Cookies
    Stream responseStream = response.GetResponseStream();
    StreamReader sr = new StreamReader(responseStream);
    StreamWriter sw = new StreamWriter("C:\\1.xml");
    sw.Write(sr.ReadToEnd());
    sw.Cloae();
    sr.Close();
    responseStream.Close();
    response.Close();
      

  4.   

    To:mngzilin这样是不行的,我首先通过你这种方法取得A页面的内容,再通过正则取到B页的地址,再去Get访问B页,没Cookie返回错误页面.Iframe貌似是通过ajax设的cookie.哪位大牛知道怎么搞?
      

  5.   


    C#俺不知道, vc下我通过传递内部的IWebBrowser2接口就可以跨域了.
      

  6.   

    获取不同域的 IWebBrowser2对象,然后获取IHTMLDocumentX 对象,读取cookie
      

  7.   

    跨域指的是主域必须相同
    不同程序,通过ajax和post实现数据传递