I have 2 listbox,
- lbProxy = contain proxy list
- lbKeyword = contain keyword list.
I want to process the keyword list, 1 keyword using 1 proxy. If number of proxy list less than keyword list, then loop proxy list again.
I don't know how to change proxy after 1 keyword is processed.
Full Code
private void useproxy()
{
foreach (string prox in lbProxy.Items)
{
WebClient fetch = new WebClient();
string numResults = nudPages.Value.ToString();
int delay = Convert.ToInt32(nudDelay.Value);
if (lblStatusProxy.InvokeRequired)
{
lblStatusProxy.Invoke(new MethodInvoker(delegate
{
lblStatusProxy.Text = "Using: " + prox;
}));
}
WebProxy wp = new WebProxy(prox);
fetch.Proxy = wp;
foreach (string kw in lbKeyword.Items)
{
keywords = kw;
if (lblStatusKeyword.InvokeRequired)
{
lblStatusKeyword.Invoke(new MethodInvoker(delegate
{
lblStatusKeyword.Text = "Processing Keyword :" + kw;
}));
}
string downloadUrl = "https://www.google.com" + "/search?q=" + kw + "&num=" + numResults + "&as_qdr=all&ei=LrUVVf7UMrPfsAS7lICgCw&sa=N&biw=1440&bih=690";
fetch.Headers.Set(HttpRequestHeader.Host, "www.google.com");
string data = fetch.DownloadString(downloadUrl);
string[] results = TopUrls(data);
foreach (string lines in results)
{
if (lbBlog.InvokeRequired)
{
lbBlog.Invoke(new MethodInvoker(delegate
{
lbBlog.Items.Add(lines);
}
));
}
}
}
}
}
Thank you,