I have a text document from 10 sites links.
I want to parse them.
I do this : I take the first url from the text doc. and go over it from the web browser.
Next parsyu. As soon as the process of parsing the first url is over, I start to parsit the 2 link, and so on.

The question is how can I make it possible to parse 10 url at once, and not one by one. (Authorization on the site) is important.

Upd. I will add a little.

Uri url = new Uri(listBox1.SelectedItem.ToString()); // закидываю с txt в list box мои url, выбираю 1 url webBrowser1.Url = url; // присваиваю браузеру выбранный url 

Then I save the html code in a separate txt and its pars

 HtmlAgilityPack.HtmlDocument d = new HtmlAgilityPack.HtmlDocument(); d.Load(@"HTML.txt"); 
  • one
    Please provide the code, it is not entirely clear what exactly is happening with you, "I take the first url from the text doc. And go over it from the web browser. Next parsi" ??? - Yury Bakharev
  • Has updated. Maybe it will be better ... - Sergiy

1 answer 1

Well, as I understand, you can try this

  static class Program { static void Main() { string[] urls = File.ReadAllLines("references.txt"); foreach(var url in urls) { Magic(GetRequest(url)); } } public static void Magic(string html) { //Тут вы можете обрабатывать данные страницы } public static string GetRequest(string uri)//Get запрос { var webRequest = WebRequest.Create(uri); webRequest.Credentials = CredentialCache.DefaultCredentials; var webResponse = webRequest.GetResponse(); var dataStream = webResponse.GetResponseStream(); var reader = new StreamReader(dataStream); var responseFromServer = reader.ReadToEnd(); reader.Close(); webResponse.Close(); return responseFromServer; } } 

It is suitable if it is GET requests and references in the references.txt file, one per line, if not, use Split () with a separator.