string url_Login_Group = "http://ui.ptlogin2.qq.com/cgi-bin/login?appid=549000912&daid=5&style=12&s_url=http%3A%2F%2Fqun.qzone.qq.com%2Fgroup%23!%2F336100817%2Fmember";
string WebCode = GetWebString(url_Login_Group);
//获取Cookie值
//string qrsig = Cookies.GetCookies(new Uri("http://ptlogin2.qq.com"))["qrsig"].Value;
//获取Cookie值
string uikey = Cookies.GetCookies(new Uri("https://xui.ptlogin2.qq.com"))["uikey"].Value;
Console.WriteLine(uikey);
Console.WriteLine(WebCode);
Console.ReadLine();
public static CookieContainer Cookies = new CookieContainer();
public static string GetWebString(string url, string referer = null, Encoding encode = null)
{
string webdat = null;
HttpWebRequest req = null;
HttpWebResponse res = null;
try
{
req = (HttpWebRequest)WebRequest.Create(url);
req.CookieContainer = Cookies;
req.AllowAutoRedirect = false;
req.Timeout = ;
req.Referer = referer;
req.Proxy = null;
req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36";
res = (HttpWebResponse)req.GetResponse();
Cookies.Add(res.Cookies);
using (StreamReader reader = new StreamReader(res.GetResponseStream(), encode == null ? Encoding.UTF8 : encode))
{
webdat = reader.ReadToEnd();
}
//using (FileStream fs = new FileStream("webdat.txt", FileMode.Create))
//{
// byte[] data = Encoding.UTF8.GetBytes(webdat);
// fs.Write(data, 0, data.Length);
//}
}
catch (HttpException httpex)
{
return "HttpException:" + httpex + "";
}
catch (WebException webex)
{
return "WebException:" + webex + "";
}
finally
{
if (res != null)
{
res.Close();
}
if (req != null)
{
req.Abort();
}
}
return webdat;
}

取Cookie值的更多相关文章

  1. Vuex 页面刷新后store保存的数据会丢失 取cookie值

    在store.js中 export default new vuex.Store({ // 首先声明一个状态 state state:{ pcid: '', postList: [], } //更新状 ...

  2. PHP curl爬取数据 加入cookie值

    public function get_cookie(){ header("Content-type:text/html;Charset=utf8"); $ch =curl_ini ...

  3. JS存取Cookie值

    一:存Cookie //存Cookie document.cookie = "id=" + escape(value); 二:取Cookie //提取Cookie值 functio ...

  4. C# .net中cookie值为中文时的乱码解决方法

    一.cookie的名称或子cookie的名称不能为中文,否则无法获得cookie 这个好办,名称不用中文即可 二.cookie的值为中文时候,取cookie的值会出现乱码 解决办法:存取cookie时 ...

  5. webBrowser获取取Cookie不全的解决方法

    //取当前webBrowser登录后的Cookie值           [DllImport("wininet.dll", CharSet = CharSet.Auto, Set ...

  6. httpclient 怎么带上登录成功后返回的cookie值访问下一页面

    我是只很菜很菜的小鸟.刚上班,有这个一个需求.要我抓取别的网站的数据.     我根据用户密码登录一个网站成功后,生成一个cookie值.我已经获取到了.然后要带上这个cookie值进行下一页面的访问 ...

  7. 在webBrowser中取Cookie的方法

    在很多情况下我们会使用间进程的webBrowser去实现一些网页的请求和抓去,这个时候有部分网页是取不到Cookie的,那怎么办呢?下面我提供一个方法,应该99%的都能取到, //取当前webBrow ...

  8. JS获取指定的cookie值

    cookie Name为TEST_COOKIE:用如下方法可以获取cookie值: document.cookie.replace(/(?:(?:^|.*;\s*)TEST_COOKIE\s*\=\s ...

  9. php取默认值以及类的继承

    (1)对于php的默认值的使用和C++有点类似,都是在函数的输入中填写默认值,以下是php方法中对于默认值的应用: <?phpfunction makecoffee($types = array ...

随机推荐

  1. windows 使用ssh连接docker容器

    在Windows上搭建docker服务器需要在Windows模拟一个Linux平台,然后在Linux平台上搭建的docker服务器,所以在使用ssh工具连接docker容器的时候,使用的ip地址不是d ...

  2. 调用caffe脚本将图片转换为了lmdb格式

    #!/usr/bin/env sh # Create the imagenet lmdb inputs # N.B. set the path to the imagenet train + val ...

  3. 【OpenGL】LNK1104 无法打开文件“freeglutd.lib”

    新建的OpenGL程序编译时经常会出现[LNK1104 无法打开文件“freeglutd.lib”]问题,如果freeglutd.lib确实放到了正确的路径下,通常可以通过添加“NDEBUG”宏定义解 ...

  4. git push 的解决方案

    如果输入$ git push origin master 提示出错信息: 或者 失败的原因:不能 push 远端仓库 原因分析:由于你当前分支落后与远程端对应分支,所以无法更新: 解决方案:使用 gi ...

  5. 还是端口回流问题 TCP协议解析

    还是上一篇的问题 在一内部局域网中, client  内网地址为 10.0.0.2     web  服务器内网地址为 10.0.0.1    外网地址为  211.6.15.1    域名为  xx ...

  6. 1282 - Leading and Trailing 求n^k的前三位和后三位。

    1282 - Leading and Trailing You are given two integers: n and k, your task is to find the most signi ...

  7. Mysql性能优化全揭秘-庖丁解牛

    「为什么写」 一直想写数据库相关的文章,最直接的原因是数据库这块我们工作中每天都会用到,也是面试求职绕不开的话题,无论你是何种测试,优秀的数据库能力都会非常加分,最近我在总结数据库性能优化这块内容,性 ...

  8. RPC(简单实现)

    笔者之前仅看过RPC这个单词,完全没有了解过,不想终于还是碰上了.起因:这边想提高并发量而去看kafka(最后折中使用了redis),其中kafka需要安装ZooKeeper,而ZooKeeper又与 ...

  9. js文本复制插件&vue

    /* HTML: * <a href="javascript:;" class="copy" data-clipboard-text="copy ...

  10. MySql学习-1.MySql的安装:

    1.安装包的下载(mysql-v5.7.25 )(NavicatforMySQL_11.2.15): 链接:https://pan.baidu.com/s/166hyyYd3DMjYhMwdW805F ...