请教(新浪模拟登录)
http://topic.csdn.net/u/20110827/22/d0c63b1f-4c28-48df-98b3-1fc5187d9f5d.html
大家帮忙看一下吧,代码如下,可是不能登录成功啊,先谢谢了。。
private void SinaLogin_Load(object sender, EventArgs e)
{
string username = "";
string password = "";
string url = "http://login.sina.com.cn/sso/prelogin.php?entry=miniblog&callback=sinaSSOController.preloginCallBack&user=" + username + "&client=ssologin.js(v1.3.12)";
url = GetUrl(url);
try
{
if (!string.IsNullOrEmpty(url))
{
int a = url.LastIndexOf(',') - 10;
int b = url.LastIndexOf(':') + 2;
string servertime = url.Substring(a, 10);
string nonce = url.Substring(b, 6);
string Pwd1 = GetPwd(password);
string Pwd2 = GetPwd(Pwd1);
string Pwd3 = GetPwd(Pwd2 + servertime + nonce);
string login = @"http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.3.12)&service:miniblog&client:ssologin.js%28v1.3.12%29&entry:miniblog&encoding:utf-8&gateway:1&savestate:0&useticket:1&username:" + username + "&servertime:" + servertime + "&nonce:" + nonce + "&pwencode:wsse&password:"+Pwd3+"&url:http://www.baidu.com&returntype:META&ssosimplelogin:1";
string result = GetUrl(login);
}
else
{
Console.WriteLine("出错了!");
}
}
catch (Exception)
{
throw;
}
}
static string GetPwd(string Pwd)
{
byte[] data = System.Text.Encoding.Default.GetBytes(Pwd);//以字节方式存储
System.Security.Cryptography.SHA1 sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
byte[] result = sha1.ComputeHash(data);//得到哈希值
return System.BitConverter.ToString(result).Replace("-", ""); //转换成为字符串的显示
}
private string GetUrl(string url)
{
string _str = string.Empty;
WebRequest request = WebRequest.Create(url);
request.Timeout = 5000;
//request.Method = "POST";
try
{
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(),System.Text.Encoding.GetEncoding("gb2312"));
_str = reader.ReadToEnd();
reader.Close();
reader.Dispose();
response.Close();
}
catch (System.Net.WebException ex)
{
//tb.Text = ex.Message;
}
return _str;
}
...全文
相关推荐
selenium模拟登录新浪微博.
内含火狐驱动,和phantomjs无壳浏览器,针对现新浪微博的登录界面有用
新浪微博模拟登录的实现方法及实战演练
在数字化的今天,自动化脚本与程序模拟登录对开发者而言并不陌生,它可以让我们在不进行手动干预的情况下与网站或应用进行交互。这一章将带您深入理解模拟登录的基本原理,并概述如何实现一个基础的登录脚本。模拟登录的基本原理是通过编程方式,构造与浏览器中相同的HTTP请求。这通常包括但不限于:模拟用户输入的用户名和密码、处理第三方认证(如验证码)、维持会话状态等步骤。这一过程需要对HTTP协议有一定的了解,以及对目标网站的登录机制有清晰的洞察。
python3.7 requests模拟新浪微博登录
python3.7 使用requests库模拟新浪微博登录。由于新浪对于用户账号和密码使用特殊加密,此程序使用base64对用户名进行编码和rsa2对password进行编码,亲测完成登录。
Java模拟登录新浪微博
NULL 博文链接:https://tonyj.iteye.com/blog/1897604
java模拟登录新浪微博
利用账号密码模拟登录新浪微博,文件中用到了shiro的base64加密以及一些JSON包,使用前请先下载。


