留着备用.
[cce_cs] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Net; namespace OpenURL { static class GetURL { static Encoding enc = Encoding.GetEncoding("GB2312"); /// <summary> /// 获取文本 /// </summary> /// <param name="txturl">URL链接</param> /// <returns>获取到的数组,每行一个</returns> public static string[] GetUrlList(string txturl) { try { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(txturl); HttpWebResponse res = (HttpWebResponse)req.GetResponse(); StreamReader reader = new StreamReader(res.GetResponseStream(), enc); string data1 = reader.ReadToEnd(); res.Close(); reader.Close(); string[] urlstr = new string[data1.Split('n').Length]; for (int i = 0; i < data1.Split('n').Length; i++) { urlstr[i] = data1.Split('n')[i]; } return urlstr; } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } return null ; } } } [/cce_cs]
不错哦 支持一个。学习呵呵呵 😥