我遇到了一个问题,我的代码在
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
我做错了什么?有时我会从队列中得到错误的代理,所以我希望能够超时并跳过。
Boolean match = false;
String clean = String.Empty;
String msbuff;
IWebProxy insideProxy;
try
{
//grab proxies based on queue
String proxyQueItem = Proxy_Que(_rankingConnectionString);
insideProxy = new WebProxy(proxyQueItem);
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(ResultURL);
request.Proxy = insideProxy;
request.Timeout = 15*1000;
using (HttpWebResponse response = (HttpWebResponse) request.GetResponse())
{
if (response.StatusCode == HttpStatusCode.OK)
{
Stream streamResponse = response.GetResponseStream();
StreamReader streamRead = new StreamReader(streamResponse);
msbuff = streamRead.ReadToEnd();
//get rid of , -, (, )
msbuff = msbuff.Replace(" ", String.Empty).Replace(" ", String.Empty);
msbuff = msbuff.Replace("-", String.Empty);
msbuff = msbuff.Replace("(", String.Empty);
msbuff = msbuff.Replace(")", String.Empty);
//attempt to find phone number
match = msbuff.Contains(Listing.PhoneNumber);
streamRead.Close();
}
}
}
catch (Exception lk)
{ }