基本信息
源码名称:C# 模拟登陆discuz论坛例子源码
源码大小:0.23M
文件格式:.zip
开发语言:C#
更新时间:2015-08-05
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Class5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
HttpCodeLib.XJHTTP http = new HttpCodeLib.XJHTTP();
private void Form1_Load(object sender, EventArgs e)
{
//;loginhash=Le8fx">
//name="formhash" value="fba244a2" />
}
private void btn_Login_Click(object sender, EventArgs e)
{
string str= http.GetHtmlString("http://www.xuanjics.com/member.php?mod=logging&action=login&infloat=yes&handlekey=login&inajax=1&ajaxtarget=fwin_content_login");
string loginhash = GetStringMid(str, ";loginhash=", "\">");
// \"="
string formhash = GetStringMid(str, "name=\"formhash\" value=\"", "\" />");
string url = string.Format("http://www.xuanjics.com/member.php?mod=logging&action=login&loginsubmit=yes&handlekey=login&loginhash={0}&inajax=1", loginhash);
string data = string.Format("formhash={0}&referer=http%3A%2F%2Fwww.xuanjics.com%2F&loginfield=username&username={1}&password={2}&questionid=0&answer=", formhash,
txtUseName.Text, txtPwd.Text);
string ret = http.GetHtmlString(url, "post", data);
MessageBox.Show(ret.Contains("欢迎您回来")?"登录成功":"登录失败");
}
/// <summary>
/// 取文本中间
/// </summary>
/// <returns></returns>
private string GetStringMid(string allStr,string firstStr,string lastStr)
{
int index1 = allStr.IndexOf(firstStr);
int index2 = allStr.IndexOf(lastStr, index1 1);
if (index1 < 0 || index2 < 0)
{
return "";
}
index1 = index1 firstStr.Length;
index2 = index2 - index1;
if (index1 < 0 || index2 < 0)
{
return "";
}
return allStr.Substring(index1, index2);
}
}
}