查找代理
这几天外网的都上不了,想更新一下空间也都不得行,更糟的是IE7.0 不稳定(说来谁也不相信:下载个Office文档.doc/.ppt载完后莫名其妙地丢失了!试了好几次在快载完的时候用右键想把它给拽住,来个 copy-paste!my God !没的了),Mathon开的页面一下子开不了,非得连续刷新两三下才见得几个页面慢慢地打开!后来给装上了 Firefox ,以前对那只丑陋的“恐龙”并不感兴趣,用来不习惯,同学说 不是这个版本的,载了个 Mozilla Firefox 果然不一样,这图标也都变成一只“狐狸”了(应该是狐狸吧,不过用“狐狸”登不了工行的,因为工行的AtiveX是针对IE内核的)。Baidu 一下,发现有 N 多插件,兴奋之时却发现每个网页都打不开,mozilla.org,mozilla.com,mozilla.???多少个域名啊,一个也访问不了!
习惯性地打开“代理猎手”,没有一个代理可用,到http://info.hustonline.net/info/index/proxyshow.aspx 找几个试试,失望了~~
还是继续把上次的项目再打开吧~
GetProxy:
今晚试了一下果然真爽!请求http://info.hustonline.net/info/index/proxyshow.aspx终于有结果了
再多加点吧:
还有可以从文件检索代理:
把结果保存为 txt 文件,之后的工作就由“花刺”来搞定了~~
习惯性地打开“代理猎手”,没有一个代理可用,到http://info.hustonline.net/info/index/proxyshow.aspx 找几个试试,失望了~~
还是继续把上次的项目再打开吧~
GetProxy:
今晚试了一下果然真爽!请求http://info.hustonline.net/info/index/proxyshow.aspx终于有结果了
private void btnWork_Click(object sender, EventArgs e)
{
result = "";//要写入txt文档的代理字符串
count = 0;//代理个数
if (tbFile.Text == "" & tbUrl.Text == "")
{
MessageBox.Show("请选择方式!", "空值");
return;
}
else
{
btnWork.Enabled = false;
btnSave.Enabled = false;
if (rbtnUrl.Checked == true)
{
url = tbUrl.Text;
type = "url";
}
else
{
url = tbFile.Text;
type = "dir";
}
//url = "http://www.gaisoft.com/2005/4-6/11470-13.html";
url = "http://info.hustonline.net/index/proxyshow.aspx";//就这个url困扰着好几天,请求其它的都可以为啥这个不行?而且浏览器是可以访问到该地址的
//有说是跟二级域名有关,但像http://msdn1.microsoft.com/en-us/default.aspx
这样的url总可访问得到吧?
//url = "http://www.sina.com";
deleWork work = new deleWork(GetProxy);
work.BeginInvoke(url, new AsyncCallback(AfterWork), null);
}
}
private void GetProxy(string para)
{
if (type == "url")
{
request = (HttpWebRequest)HttpWebRequest.Create(para);
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
stream = response.GetResponseStream();
reader = new StreamReader(stream, Encoding.Default);
tmp = reader.ReadToEnd();
mchColl = ipRegex.Matches(tmp);
foreach (Match match in mchColl)
{
result += match.ToString() + "\r\n";
}
count = mchColl.Count;
MessageBox.Show("一共找到 " + count.ToString() + " 个代理");
}
else
{
try
{
tmp = File.ReadAllText(tbFile.Text, Encoding.Default);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
mchColl = ipRegex.Matches(tmp);
foreach (Match match in mchColl)
{
result += match.ToString() + "\r\n";
}
count = mchColl.Count;
MessageBox.Show("一共找到 " + count.ToString() + " 个代理");
}
}
private void AfterWork(IAsyncResult result)
{
object[] o = { this, System.EventArgs.Empty };
btnWork.BeginInvoke(new System.EventHandler(UpdateUI), o);
}
private void UpdateUI(object o, System.EventArgs e)
{
btnSave.Enabled = true;
btnWork.Enabled = true;
}
这是”花刺“查找”华中大的代理,只查出9个来:{
result = "";//要写入txt文档的代理字符串
count = 0;//代理个数
if (tbFile.Text == "" & tbUrl.Text == "")
{
MessageBox.Show("请选择方式!", "空值");
return;
}
else
{
btnWork.Enabled = false;
btnSave.Enabled = false;
if (rbtnUrl.Checked == true)
{
url = tbUrl.Text;
type = "url";
}
else
{
url = tbFile.Text;
type = "dir";
}
//url = "http://www.gaisoft.com/2005/4-6/11470-13.html";
url = "http://info.hustonline.net/index/proxyshow.aspx";//就这个url困扰着好几天,请求其它的都可以为啥这个不行?而且浏览器是可以访问到该地址的
//有说是跟二级域名有关,但像http://msdn1.microsoft.com/en-us/default.aspx
这样的url总可访问得到吧?
//url = "http://www.sina.com";
deleWork work = new deleWork(GetProxy);
work.BeginInvoke(url, new AsyncCallback(AfterWork), null);
}
}
private void GetProxy(string para)
{
if (type == "url")
{
request = (HttpWebRequest)HttpWebRequest.Create(para);
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
stream = response.GetResponseStream();
reader = new StreamReader(stream, Encoding.Default);
tmp = reader.ReadToEnd();
mchColl = ipRegex.Matches(tmp);
foreach (Match match in mchColl)
{
result += match.ToString() + "\r\n";
}
count = mchColl.Count;
MessageBox.Show("一共找到 " + count.ToString() + " 个代理");
}
else
{
try
{
tmp = File.ReadAllText(tbFile.Text, Encoding.Default);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
mchColl = ipRegex.Matches(tmp);
foreach (Match match in mchColl)
{
result += match.ToString() + "\r\n";
}
count = mchColl.Count;
MessageBox.Show("一共找到 " + count.ToString() + " 个代理");
}
}
private void AfterWork(IAsyncResult result)
{
object[] o = { this, System.EventArgs.Empty };
btnWork.BeginInvoke(new System.EventHandler(UpdateUI), o);
}
private void UpdateUI(object o, System.EventArgs e)
{
btnSave.Enabled = true;
btnWork.Enabled = true;
}
再多加点吧:
还有可以从文件检索代理:
把结果保存为 txt 文件,之后的工作就由“花刺”来搞定了~~