获取网页中指定的字符串信息
2012-02-05 20:45
190 查看
获取网页中指定的字符串信息,这个是获取百度的
private void button2_Click(object sender, EventArgs e) { // Create a request for the URL. WebRequest request = WebRequest.Create("http://www.baidu.com/"); // If required by the server, set the credentials. request.Credentials = CredentialCache.DefaultCredentials; // Get the response. HttpWebResponse response = (HttpWebResponse)request.GetResponse(); // Display the status. MessageBox.Show(response.StatusDescription); Console.WriteLine(response.StatusDescription); // Get the stream containing content returned by the server. Stream dataStream = response.GetResponseStream(); // Open the stream using a StreamReader for easy access. StreamReader reader = new StreamReader(dataStream, Encoding.Default); // Read the content. string responseFromServer = reader.ReadToEnd(); //截取数据 int i = responseFromServer.IndexOf("京"); string dataBid = responseFromServer.Substring(i, 12); // Display the content. MessageBox.Show(dataBid); Console.WriteLine(responseFromServer); // Cleanup the streams and the response. reader.Close(); dataStream.Close(); response.Close(); }
相关文章推荐
- c# 获取网页中指定的字符串信息的实例代码
- 根据查询的关键字,实现获取百度指定页数的搜索结果的信息(网页地址,标题,摘要,并有排序的说明)
- 微信开发笔记——微信网页登录授权,获取用户信息
- python获取网页amf的信息
- PHP/微信网页授权获取用户基本信息
- 获取指定字符串中的图片地址,逗号分隔
- C# WebBrowser获取指定字符串的坐标
- C# 获取指定HTML网页中的标签内容
- 正则表达式相关:C# 抓取网页类(获取网页中所有信息)
- 获取错误信息并到指定页面
- 微信网页中获取用户基本信息(网页授权操作)
- 获取屏幕分辨率及网页信息
- MFC获取版本指定信息方法
- 在python使用selenium获取动态网页信息并用BeautifulSoup进行解析--动态网页爬虫
- 微信网页授权获取用户基本信息
- 微信公众号获取用户信息-网页授权
- 微信网页开发授权(获取用户信息) 微信公众平台开发教程(4)
- JAVA之IO技术-获取指定目录下的文件夹和文件的File对象或是字符串名称。
- 微信公众号开发系列-网页授权获取用户基本信息
- 支付宝二(网页授权获取用户信息)