您的位置:首页 > 其它

小偷程序获取新闻标题及内容

2008-09-17 21:44 225 查看
利用字符串截取的方法抓取所需内容

*注意*:</div>\r\n\r\n\r\n<!--正文内容 -->,看得到的内容里是否包含要截取内容,否则报错!并

且div要匹配,否则影响样式。

用 while(html.IndexOf("<li>")!=-1){}循环得到里面每个标题, html=html.Substring

(html.IndexOf("</a></li>")+"</a></li>".Length);//每循环一次排除一个li

private void Linkbutton9_Click(object sender, System.EventArgs e)

//和讯新闻内容抓取

protected Components.Entity.Article GetContentHXWeb(string url,string title,string

type)

取出新闻内容去掉里面的链接,调用方法trimTagA

public static string trimTagA(string strHtml)

下载事件

private void btDownLoad_Click(object sender, System.EventArgs e)

{

{

{

{

{

{

Components.Entity.Article at = new Components.Entity.Article

();

at.ClassId = Convert.ToInt32(strType);

at.Date = DateTime.Now;

at.Title = Title.Text;

at.Content= Content.Text;

at.PassDate = DateTime.Now;

at.Pass = 1;

at.PassUserId = Components.Context.GetAdministrator().Id;

at.TopicType = (int)Components.Enum.TopicType.Bank;

at.Insert();

}

}

}

Response.Write("<script>alert('下载完成!')</script>");

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐