Note that there are some explanatory texts on larger screens.

plurals
  1. PO.NET C# - webBrowser.Navigate to next URL doesnt work always
    text
    copied!<p>I have a List of URLs in a textfile which i want to visit using the C# webBrowser class and save the content of every website to somewhere. The problem is, that the program doesn't always visit the new URL.</p> <p>Link 1 and 2 is visited correctly, then the browser window doesn't refresh on link 3. Link 4 works again, while 5, 6 and 7 fails. Link 8 works, 9 to 15 fails. 16 Works and so on...</p> <p>Here is an example list of URLs:</p> <p><code>http://www.example.com/somefile_7.html*SomeOtherText1*SomeAdditionalText1</code></p> <p><code>http://www.example.com/somefile_12.html*SomeOtherText1*SomeAdditionalText2</code></p> <pre><code>static int counter_getURL = 0; private void Form1_Load(object sender, EventArgs e) { nextTurn(); } void startBrowser(string url) { webBrowser1.Navigate(new Uri(url), "_self"); webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(get_browser_string); } void get_browser_string(object sender, WebBrowserDocumentCompletedEventArgs e) { // Display the content of the website in textBox1 textBox1.Text = webBrowser1.Document.Body.InnerText; MessageBox.Show("Next"); nextTurn(); } public void nextTurn() { startBrowser(getURL()); } public string getURL() { string url = ""; string[] input = System.IO.File.ReadAllLines(@"C:\Users\WORKSTATION01\Desktop\url_list.txt", Encoding.Default); // Get the URL only string[] splitted = input[counter_getURL].Split(new char[] { '*' }); url = splitted[0]; counter_getURL++; return url; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload