(Forum Q & A Drop) How to determine whether the link is valid and gets the source code if it is effective

xiaoxiao2021-03-06  14

WebRequest myWebRequest = WebRequest.Create ( "a broken link address"); myWebRequest.Timeout = 5000; try {WebResponse myWebResponse = myWebRequest.GetResponse (); Stream resStream = myWebResponse.GetResponseStream (); StreamReader sr = new StreamReader (resStream, System.Text.Encoding.default); this.label1.text = sr.readToend (); resstream.close (); sr.close ();} catch (system.net.webexception xx) {this.label1.text = XX.Message;}

If the Label tag is displayed: invalid address 404 error Description Link is invalid

转载请注明原文地址:https://www.9cbs.com/read-48106.html

New Post(0)