How can I programatically get internet traffic fro

2019-08-18 03:00发布

问题:

How do I programatically get internet traffic from a web site in C# or C++?

I mean, how can this be done without opening up a browser or a broswer control?

Additionally, there is some sort of plugin to a browser in IE and others where you can watch the communication from a browser to a server and back. Does anyone know about this?

回答1:

If you are looking for programmaticaly requesting web pages then you might check httpwebrequest in C#.

Additionally, there is some sort of plugin to a browser in IE and others where you can watch the communication from a browser to a server and back. Does anyone know about this?

you can check fiddler.



回答2:

Look into cURL for C++ http://curlpp.org/ or if you want more low-level communication processing check socket programming and winsock. You'll connect to a server on a port and send a GET request, the server will respond with the HTML code if the page is an HTML, etc.

You will have to have some basic HTTP protocol knowledge though. http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol



回答3:

Use the WebClient.DownloadString() or DownloadStringAsync() with the address of the web site.



回答4:

WebClient and HttpWebRequest can be used to communicated with servers without a browser

http://msdn.microsoft.com/en-au/library/system.net.webclient(VS.80).aspx

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx

Fiddler can be used to watch the browser communication

http://www.fiddler2.com/fiddler2/version.asp



回答5:

You can use System.Net.HttpWebRequest, which lets you send http get and http post requests.