(02-28-2013, 03:46 AM)Cyber-Savage Wrote: Did you make this? Because I don't see any credits.
It's only 2 methods of code, how hard could it have been? :huh:
...
Code:
private void button_Click_1(object sender, EventArgs e)
{
webBrowser1.ScriptErrorsSuppressed = true;
webBrowser1.Navigate("https://www.facebook.com/find-friends/browser/");
webBrowser1.DocumentCompleted += webBrowser1_DocumentCompleted;
}
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
for (int i = 0; i < 700; i++)
{
if (webBrowser1.Document.All[i].Id != null)
if (webBrowser1.Document.All[i].Id.StartsWith("u_"))
webBrowser1.Document.All[i].InvokeMember("click");
}
System.Threading.Thread.Sleep(10000);
webBrowser1.Navigate("https://www.facebook.com/find-friends/browser/");
}
On every button click you are adding the handler to the DocumentCompleted event method? Why...
Your loop:
Code:
for (int i = 0; i < 700; i++)
{
if (webBrowser1.Document.All[i].Id != null)
if (webBrowser1.Document.All[i].Id.StartsWith("u_"))
webBrowser1.Document.All[i].InvokeMember("click");
}
I think it's safe to say that as soon as we find an ID that doesn't exist we won't find another after that, so why not place a break; in here at that time to avoid unnecessary checks to all the rest of the iterations? The issue here is that you're using 700 as a constant value as well hardcoded into the program. Why not make it dynamic? Check the number of values you can find?
I don't use fb though so I can't say. I'm assuming it's in sequential ascending order though for each of the results on that search page.
Code:
System.Threading.Thread.Sleep(10000);
webBrowser1.Navigate("https://www.facebook.com/find-friends/browser/");
Absolute worst thing you can do... Very abusive way of using Thread.Sleep().