用过火车头采集软件的进来!!

egeg3000 2009-03-05 01:30:33
请问各位大虾,小弟想实现一个自动采集当当网图书排行书名到自己网站上,有两点疑问:
火车头可以采集当当这类动态网站么?
必须更新到自己真实有域名的网站么?本地网站不行吗?可以的话要怎么改?
在asp.net下怎么实现。。。
...全文
590 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
egeg3000 2009-03-05
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 sp1234 的回复:]
如果在csdn上做广告,最好只给免费软件做广告。
[/Quote]
哇塞,大哥这都能被你看出来?那你教教我怎么用我就告诉你我是不是做广告。。。
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 egeg3000 的回复:]
引用 3 楼 jijunwu 的回复:
http://topic.csdn.net/u/20090305/13/0e650295-762d-4844-8c64-ce24b6e72645.html

看看 可以参考一下

大哥,回帖也没有这么不专业的吧。。。你引用的就是我的帖子。。。
[/Quote]

晕 弄错了哦

/// <summary>
/// 分析并整理信息
/// </summary>
/// <returns></returns>
public string[] GetInfo()
{
WebClient wc = new WebClient();//创建WebClient对象
string msg;
try
{
byte[] byDats = wc.DownloadData(this.TextBox1.Text);//下载指定的Url资源
msg = UnicodeEncoding.Default.GetString(byDats);//转换编码
}
catch (Exception ex)
{
msg = ex.Message;
}
#region 正则切割
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"·\s*<a[^>]*>(?<title>[^<]*)</a>\s*<font[^>]*>(?<date>[^<]*)</font>");
string result = string.Empty;
foreach (Match m in reg.Matches(msg))
{
result += m.Groups["title"].Value + ",";//新闻标题
result += m.Groups["date"].Value + "|" + "\r\n";//时间
}
#endregion 正则切割结束

string[] strResult = result.Split('|');
ArrayList al = new ArrayList();
for (int i = 0; i < strResult.Length; i++)
{
al.Add(strResult[i]);

}
string[] ds;
ArrayList al2 = new ArrayList();
for (int i = 0; i < al.Count; i++)
{
ds = al[i].ToString().Split(',');
foreach (string s in ds)
{
al2.Add(s);
}
}
return (string[])al2.ToArray(typeof(string));
}

/// <summary>
/// 获取文章标题
/// </summary>
/// <returns></returns>
public string[] GetTitle()
{
ArrayList al = new ArrayList();
string[] Titles = GetInfo();
for (int i = 0; i < Titles.Length; i++)
{
if ((i % 2) == 0)
{
al.Add(Titles[i]);
}
}
return ((string[])al.ToArray(typeof(string)));
}
/// <summary>
/// 获取文章发布日期
/// </summary>
/// <returns></returns>
public string[] GetDate()
{
ArrayList al = new ArrayList();
string[] Dates = GetInfo();
for (int i = 0; i < Dates.Length; i++)
{
if ((i % 2) != 0)
{
al.Add(Dates[i]);
}
}
return ((string[])al.ToArray(typeof(string)));
}
/// <summary>
/// 显示数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button2_Click(object sender, EventArgs e)
{
string[] ss = GetTitle();
Response.Write("标题"+"<br>");
for (int i = 0; i < ss.Length; i++)
{
Response.Write(ss[i]);
Response.Write("<br>");

}
string[] ss2 = GetDate();
Response.Write("日期"+"<br>");
for (int j = 0; j < ss2.Length; j++)
{
Response.Write(ss2[j]);
Response.Write("<br>");
}

}
protected void Button3_Click(object sender, EventArgs e)
{
string [] titles=GetTitle();
string [] dates=GetDate();
for (int i = 0; i < ((titles.Length + dates.Length) / 2); i++)
{
Insert(titles[i], dates[i]);
}


}

public void Insert(string title,string date)
{
string connStr = System.Configuration.ConfigurationManager.ConnectionStrings["conn"].ToString();
SqlConnection conn = new SqlConnection(connStr);
string sqlStr = "insert into news(title,sendtime) values(@title,@date)";
SqlCommand cmd = new SqlCommand(sqlStr,conn);
cmd.Parameters.Add("@title",SqlDbType.VarChar,200);
cmd.Parameters.Add("@date",SqlDbType.VarChar,50);
cmd.Parameters["@title"].Value = title;
cmd.Parameters["@date"].Value = date;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
  • 打赏
  • 举报
回复
如果在csdn上做广告,最好只给免费软件做广告。
young5335 2009-03-05
  • 打赏
  • 举报
回复
动态网站可采.
只要有IP就可以实现更新,不论是域名或本机网站.步骤跟发布到网站一样
egeg3000 2009-03-05
  • 打赏
  • 举报
回复
自己顶~~
egeg3000 2009-03-05
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 jijunwu 的回复:]
http://topic.csdn.net/u/20090305/13/0e650295-762d-4844-8c64-ce24b6e72645.html

看看 可以参考一下
[/Quote]
大哥,回帖也没有这么不专业的吧。。。你引用的就是我的帖子。。。
sharpblade 2009-03-05
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 che2piaopiao 的回复:]
只要是采集软件都能采集.

除了一种情况: 代码加了限制或权限,你无法采集 .

就算能采集,,触犯了权限,甚至违法. 那样就不太好了
[/Quote]


这个你都懂..
Terry717 2009-03-05
  • 打赏
  • 举报
回复
没弄过,

帮顶!!!
che2piaopiao 2009-03-05
  • 打赏
  • 举报
回复
只要是采集软件都能采集.

除了一种情况: 代码加了限制或权限,你无法采集 .

就算能采集,,触犯了权限,甚至违法. 那样就不太好了

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧