访问太频繁拒绝访问怎么办?

artwl_cn 2010-12-05 05:36:05
小弟写了一个博客备份工具,在备份的过程中要对每篇博客地址进行访问,取得网页源码进行备份。
现在遇到的问题是,当备份到150篇左右时,网站拒绝访问了,也就是说访问太频繁被拒绝了,这个备份程序放在一个单独的类库中,请问怎么控制访问的频率(能不能用线程等待实现,如果能请指点一下),有没有其他好的解决方案?
简要代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;

namespace BlogMoveLib
{
public class BlogAnalysis
{
public IList<Blog> Analysis(IList<string> BlogAllUrl)
{
string content;
Blog model=new Blog();
IList<Blog> blogList = new List<Blog>();
foreach(string url in BlogAllUrl)
{
content=GetHtml(url);
model = GetBlogInfo(content);
blogList.Add(model);
}
if (blogList.Count > 0)
return blogList;
return null;
}

/// <summary>
/// 获得网址原代码
/// </summary>
/// <param name="Url">网址</param>
/// <returns>string</returns>
private string GetHtml(string Url)
{
//过程省略
}

/// <summary>
/// 解析博客主体
/// </summary>
/// <param name="content">网页源码</param>
/// <returns>博客实体</returns>
private Blog GetBlogInfo(string content)
{
//...过程省略
}
}
}
...全文
1359 24 打赏 收藏 转发到动态 举报
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
vip__888 2010-12-06
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 winner2050 的回复:]
那就冒充搜索引擎,我采集文章都这么用。

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.AllowAutoRedirect = true;
request.UserAgent = "Googlebot/2.1 (+http://www.google.com/bot.html)";
requ……
[/Quote]
很好啊 不错
phil999 2010-12-06
  • 打赏
  • 举报
回复
1,慢点采
2,做个进度保存
3,搜索引擎不会短时间发送大量请求,但是可以试试冒充
jeven_xiao 2010-12-06
  • 打赏
  • 举报
回复
你没有理由去买几台机吧~软件的成本是一个大的提前


HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.AllowAutoRedirect = true;
request.UserAgent = "Googlebot/2.1 (+http://www.google.com/bot.html)";
request.Referer = string.Concat("http://", uri.Host);

支持一下
zj_csdn 2010-12-06
  • 打赏
  • 举报
回复
我觉得你也可以安装一下你的软件来,处理一下IIS的设置“Web Application Stress”
微工程 2010-12-05
  • 打赏
  • 举报
回复
那就冒充搜索引擎。

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.AllowAutoRedirect = true;
request.UserAgent = "Googlebot/2.1 (+http://www.google.com/bot.html)";
request.Referer = string.Concat("http://", uri.Host);
Rock870210 2010-12-05
  • 打赏
  • 举报
回复
没搞过采集,帮顶了。。。。
mayanly 2010-12-05
  • 打赏
  • 举报
回复
虚拟机虚一台不就得了
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 durongjian 的回复:]

引用 5 楼 sp1234 的回复:

没有什么好的“频率”方案。就应该多用几台机器,然后每台机器只要能访问服务就使劲搞定服务,它再怎么拒绝也拿你没脾气。

呵呵,谢谢你的方案,可我就一台机子啊
[/Quote]

那就认栽了吧。我自己家里都有三台机器、两个ip的。
whrspsoft3723 2010-12-05
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 winner2050 的回复:]
那就冒充搜索引擎,我采集文章都这么用。

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.AllowAutoRedirect = true;
request.UserAgent = "Googlebot/2.1 (+http://www.google.com/bot.html)";
requ……
[/Quote]
高,学习了!
天下在我心 2010-12-05
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 durongjian 的回复:]
引用 5 楼 sp1234 的回复:

没有什么好的“频率”方案。就应该多用几台机器,然后每台机器只要能访问服务就使劲搞定服务,它再怎么拒绝也拿你没脾气。

呵呵,谢谢你的方案,可我就一台机子啊
[/Quote]
找代理,伪装IP地址等。
winner2050 2010-12-05
  • 打赏
  • 举报
回复
绕过过访问频率现在。
========
绕过访问频率限制。
winner2050 2010-12-05
  • 打赏
  • 举报
回复
那就冒充搜索引擎,我采集文章都这么用。

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.AllowAutoRedirect = true;
request.UserAgent = "Googlebot/2.1 (+http://www.google.com/bot.html)";
request.Referer = string.Concat("http://", uri.Host);

倒数第二段是冒充搜索引擎绕过过访问频率现在。

最后一段是冒充来源用来绕过图片、下载的反盗链。
deoing 2010-12-05
  • 打赏
  • 举报
回复
可以测试下连接多长时间或多少篇就会被拒绝?还有拒绝的时长?根据这两个参数来设计你的“频率方案”。
artwl_cn 2010-12-05
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 sp1234 的回复:]

没有什么好的“频率”方案。就应该多用几台机器,然后每台机器只要能访问服务就使劲搞定服务,它再怎么拒绝也拿你没脾气。
[/Quote]
呵呵,谢谢你的方案,可我就一台机子啊
  • 打赏
  • 举报
回复
没有什么好的“频率”方案。就应该多用几台机器,然后每台机器只要能访问服务就使劲搞定服务,它再怎么拒绝也拿你没脾气。
  • 打赏
  • 举报
回复
哦,应该是“半分钟”,不是“半秒钟”。
  • 打赏
  • 举报
回复
多使用一些机器去采集,这样每一台机器遇到拒绝就适当休息个半秒钟吧。
artwl_cn 2010-12-05
  • 打赏
  • 举报
回复
1楼的大哥说的是什么意思啊,谁能帮忙详细解释一下
wuyq11 2010-12-05
  • 打赏
  • 举报
回复
延迟操作
System.Threading.Timer t = new System.Threading.Timer(new TimerCallback(test));
t.Change(1000, 1000);
private void test(object state)
{
System.Threading.Timer t2 = new System.Threading.Timer(new TimerCallback(test2));
t2.Change(1000, Timeout.Infinite);
}

62,025

社区成员

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

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

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

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