如何用.Net 取得指定网面的内容? How to get html web page data?
来源:互联网 发布:php socket例子 编辑:程序博客网 时间:2024/05/16 11:32
using System;
using System.IO;
using System.Net;
using System.Text;
namespace Examples.System.Net
{
public class WebRequestGetExample
{
public static void Main()
{
// Create a request for the URL.
WebRequest request = WebRequest.Create(
"http://www.microsoft.com/default.aspx");
WebProxy pry = new WebProxy("192.168.1.1", 8080);
//The DefaultCredentials automically get username and password.
pry.Credentials = CredentialCache.DefaultCredentials;
//GlobalProxySelection.Select = pry;
request.Proxy = pry;
// If required by the server, set the credentials.
request.Credentials = CredentialCache.DefaultCredentials;
// Get the response.
WebResponse response = request.GetResponse();
// Display the status.
Console.WriteLine(((HttpWebResponse)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);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
Console.WriteLine(responseFromServer);
// Clean up the streams and the response.
reader.Close();
response.Close();
// stop the console screen for user check data
Console.ReadLine();
}
}
}
- 如何用.Net 取得指定网面的内容? How to get html web page data?
- How to get a web page content type
- 如何用VC中的CHtmlView取得网页的HTML源码
- How to save a web page as HTML or MHT
- How to get random number within a range using C++ - 如何用C++获取一定范围内的随机数
- How To Convert HTML Page To Image
- how to get pdf page numbers
- [VB.NET]如何用打开指定文件
- How to grab web page in chinese
- 教你如何用java取得web工程目录
- 教你如何用java取得web工程目录
- How To Get Properties Data in Spring
- How to Get Started in Data Science
- How to deploy a .Net assmebly for COM use through CAB on Web Page (转)
- How to deploy a .Net assmebly for COM use through CAB on Web Page
- xcode如何用代码打开指定的文件夹目录并显示目录内容
- 如何用vb.net下载web页
- [ZT]Submitting Web Form data from one ASP.NET page to another
- select 左右移动
- delphi调用腾讯通发即时消息
- Mysql命令
- Windows XP 安装 GT4.0.2
- Activity生命周期方法
- 如何用.Net 取得指定网面的内容? How to get html web page data?
- WinCE 流接口驱动中设备句柄的传输过程
- myclipes+tomcat6+mysql5(linux)环境下tomcat启动应用出现死循环
- linux线程(pthread)编程中的segmentation fault!!
- typedef和define具体的详细区别
- 春节休假只有7天
- alsa驱动分析之一
- 已解决:Linux中用socket实现视频、音频的同步传输
- ARM指令集和X86指令集的比较