简体   繁体   English

如何使WebClient请求所有其他GET请求

[英]How make WebClient request all others GET requests

I am trying to simulate a real web browser request and turns out when I use this code: 我正在尝试模拟真实的Web浏览器请求,并在我使用此代码时结果:

WebClient client = new WebClient();
client.DownloadFile(address, localFilename);

I get only the GET to the address(of course) and the behavior in a browser is many GET requests to images, blogger, etc... 我只获得GET到地址(当然),浏览器中的行为是对图像,博主等的许多GET请求......

Is there a shortcut to get/simulate the same behavior or the only alternative is to parse the file/string and make all these requests by myself manually? 是否有获取/模拟相同行为的快捷方式,或唯一的选择是解析文件/字符串并自己手动发出所有这些请求?

Yes, a browser processes the specific type of file (typically HTML) and it parses it. 是的,浏览器处理特定类型的文件(通常是HTML)并解析它。 Depending on what the file contains (links to other files like images, etc.) the browser will then start up many other connections to get all those other files to display within the browser. 根据文件包含的内容(指向图像等其他文件的链接),浏览器将启动许多其他连接,以便在浏览器中显示所有其他文件。

That doesn't come for free--you have to do that yourself. 这不是免费的 - 你必须自己做。 DownloadFile just downloads a file, that may or may not be an HTML file and thus it doesn't handled all possible file types and process all linked files. DownloadFile只下载一个文件,该文件可能是也可能不是HTML文件,因此它不处理所有可能的文件类型并处理所有链接文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM