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. Zabbix:主动模式

    简介 Zabbix 是由 Alexei Vladishev 开发的一种网络监视.管理系统,基于 Server-Client 架构.可用于监视各种网络服务.服务器和网络机器等状态,官方站点:https: ...

  2. json-server的简单使用

    json-server是一个在前端本地运行,可以存储json数据的server(服务器),该服务器只支持 get 方法获取,不支持 post 方法获取,使用express工具可以使用post方法. V ...

  3. Python3(八) 枚举详解

    一.枚举其实是一个类 建议标识名字用大写 1.枚举类: from enum import Enum class VIP(Enum):     YELLOW = 1     GREEN = 2      ...

  4. ubuntu下怎么配置/查看串口-minicom工具

    一.安装minicom工具: 可直接使用命令sudo apt-get install minicom来完成安装 上面的截图因为检测到我已经安装过了. 二.通过minicom工具配置串口: 1.启动mi ...

  5. RF-ui自动化

    1.关于时间等待 Wait Until Keyword Succeeds      3x      300ms       Wait Until Element Is Visible      ${x ...

  6. CentOS7.3下yum安装MariaDB10.3.12并指定utf8字符集

    添加MariaDB的yum源,指定安装的版本,然后使用 yum 工具进行安装 参考MariaDB官方网站对应安装方法和步骤 https://downloads.mariadb.org/mariadb/ ...

  7. 软件bug描述(web)

    1.bug编码与名称:测试日期+bug字段 2.测试环境:浏览器:全部/IE8,操作系统:win7 x64 3. 测试数据:用户名,密码,相关的业务账号 4.重现步骤:缺陷发现的过程 5. 缺陷说明: ...

  8. [Linux]curl 测试socket http代理

    Socket5 curl --socks5 10.2.46.19:10808 http://www.baidu.com #-----查询结果----- <!DOCTYPE html> &l ...

  9. jQuery-Moblie在Chrome下出现的问题

    第一次用jQuery然后就遇到很蛋疼的地方,打开页面一直处在菊花状态,一开始以为自己搞错什么,是不是引用错文件,看里面的错误警告 Failed to execute 'replaceState' on ...

  10. input event兼容性

    <div class="wrapper"> <p>keypress - event not call on adroid</p> <inp ...