110,539
社区成员
发帖
与我相关
我的任务
分享
<div id="SinaEditor_Iframe">
<iframe class="iframe"></iframe>
</div>
#region 新浪
private void button12_Click(object sender, EventArgs e)
{
this.webBrowser1.Url = new System.Uri("http://blog.sina.com.cn/", System.UriKind.RelativeOrAbsolute);
}
/// <summary>
/// 登录新浪
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button13_Click(object sender, EventArgs e)
{
//获得用户名
HtmlElement tbUserid = webBrowser1.Document.GetElementById("loginName");
//获得密码
HtmlElement tbUserpwd = webBrowser1.Document.GetElementById("loginPass");
//获得登录按钮
HtmlElement button = webBrowser1.Document.GetElementById("loginButton");
if (tbUserid != null && tbUserpwd != null && button != null)
{
//给用户名赋值
tbUserid.SetAttribute("value", "vampire_ycq@sina.com");
//设置密码
tbUserpwd.SetAttribute("value", "88.YCQ.88");
//登录
button.InvokeMember("click");
}
}
/// <summary>
/// 写博客
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button14_Click(object sender, EventArgs e)
{
//跳转到写博文的页面
this.webBrowser1.Url = new System.Uri("http://control.blog.sina.com.cn/admin/article/article_add.php?index", System.UriKind.RelativeOrAbsolute);
}
/// <summary>
/// 发博文
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button15_Click(object sender, EventArgs e)
{
//博客标题
HtmlElement title = webBrowser1.Document.GetElementById("articleTitle");
//博客提交按钮
HtmlElement button = webBrowser1.Document.GetElementById("articlePostBtn");
////////////我找不到的博客正文////////////////
HtmlElement body = webBrowser1.Document.GetElementById(" ");
//是否取到元素
if (title != null && body != null && button != null)
{
MessageBox.Show("存在");
title.SetAttribute("value", this.textBox1.Text);
body.SetAttribute("value", this.richTextBox1.Text);
button.InvokeMember("click");
}
}
#endregion