samedi 15 septembre 2018

C# - Multi-Threading with WebClient

I wanted to ask if it's possible to do multi-threading with WebClient?

Parallel.ForEach(Keywords, s =>
        {
            for (int i = 0; i < Pages; i++)
            {
                string url = URLdownloader.DownloadString("https://www.bing.com/search?q=" + s + "&first=" + i + "0");
                MatchCollection urlCollection = Regex.Matches(url.ToString(), @"(\Whttp:\/\W[a-z./?=A-Z0-9&-]+)");
                foreach (Match m in urlCollection)
                {
                    urlsdownload.Add(m.ToString().Replace(@"""", ""));
                    urlsdownload = urlsdownload.Distinct().ToList();
                    File.WriteAllLines(
                        @"C:\Users\username\Desktop\DorkWorker\URLparser\Bing.txt".Replace("username",
                            Environment.UserName), urlsdownload);
                }
            }
        });

let's say I have 100 URLs, instead of checking 1 by 1, how is it possible to check 10 at the same time? or 5?




Aucun commentaire:

Enregistrer un commentaire