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-12-26
  • 2021-12-31
  • 2021-11-22
  • 2021-07-07
  • 2021-12-13
  • 2022-01-19
猜你喜欢
  • 2022-01-08
  • 2021-11-20
  • 2021-07-17
  • 2021-12-13
  • 2021-05-21
相关资源
相似解决方案