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

Deadly 提交于 2019-12-12 06:17:25

问题


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.



来源:https://stackoverflow.com/questions/4721244/how-can-i-programatically-get-internet-traffic-from-a-web-site-in-c-sharp-or-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!