循环内循环以检查 whois 响应
尝试思考如何编码的一些逻辑。
我基本上正在创建 ac# windows 应用程序来检查域是否可用于注册 - 通过发布和检索 whoIS 记录中的数据。
我有一个包含域扩展名的文本文件,用户输入“DOMAINNAME”,
然后程序将循环遍历文件中的所有域扩展名,并报告哪些可用。
理论上这工作正常,但我目前正在实现代理支持。代理也存储在文本文件中。
我基本上在 foreach 循环中拥有域扩展,
foreach(domainExtension in domainFile)
{
checkDomainAvailability()
}
我需要的是 checkDomainAbility 方法为每个请求使用不同的代理。 关于编码背后的逻辑有什么想法吗?
trying to think of some logic of how to code this.
I'm basically creating a c# windows app to check if a domain is available for registration - by posting and retrieving data from whoIS records.
i have a text file with domain extensions in and the user types in "DOMAINNAME"
then the program will cycle through all of the domain extensions in the file and will report back which ones are available.
This in theory is working fine but im currently implementing proxy support. the proxies are also being stored in a text file.
i basically have the domain extensions in a foreach loop
foreach(domainExtension in domainFile)
{
checkDomainAvailability()
}
what i need is for the checkDomainAbility method to use a different proxy for each request.
Any ideas on logic behind coding this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将所有代理放入一个列表中,并保留一个类级别变量
int lastUsedProxy
。然后 checkDomainAvailability 函数仅使用这两个变量来获取下一个代理并递增整数。一旦lastUsedProxy >然后 List.Count 将其重置为零。使用此逻辑,您可以将比域扩展更多的代理放入列表中(即您可以有 30 个代理,但只能有 10 个扩展,代理每三个查询只会使用一次)。我认为这与您想要的类似。我认为您的目的之一是尽可能分散代理之间的负载,这种逻辑可以让您轻松做到这一点。You could put all of the proxies in a List and keep a class level variable
int lastUsedProxy
. Then the checkDomainAvailability function just uses those two variables to get the next in line proxy and increment the integer. Once lastUsedProxy > List.Count then reset it to zero. Using this logic you can put more proxies into the list than you have domain extentions (i.e. you can have 30 proxies and only 10 extensions, the proxies will only be used once every three queries). I think this is similar to what you want. I think one of your purposes is to spread the load between proxies as much as possible and this logic would allow you to do that easily.