简体   繁体   中英

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:

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...

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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