lushixiong
            WebClient we = new WebClient();  //主要使用WebClient类
            byte[] myDataBuffer;
            myDataBuffer = we.DownloadData(textBox1.Text.Trim() );  //该方法返回的是 字节数组,所以需要定义一个byte[]
            string download = Encoding.UTF8.GetString(myDataBuffer);  //对下载的数据进行编码
            //通过查询源代码,获取某两个值之间的新闻内容
          
            int startIndex = download.IndexOf("<a class=\'toindex\' href=\'/\'>");
            //int endIndex = download.IndexOf("<a\'>");
            MessageBox.Show(startIndex.ToString());
            string temp = download.Substring(startIndex,  startIndex + 30);  //截取新闻内容
            
            textBox2.Text  = temp;//显示所截取的新闻内容

            MessageBox.Show("成功");

 

分类:

技术点:

相关文章:

  • 2021-10-07
  • 2021-12-14
  • 2021-09-09
  • 2021-10-13
  • 2021-08-15
  • 2021-08-01
  • 2021-08-01
  • 2021-12-14
猜你喜欢
  • 2021-05-21
  • 2021-09-18
  • 2021-08-01
  • 2021-11-23
  • 2021-12-31
  • 2021-12-26
  • 2021-11-01
相关资源
相似解决方案