I'm trying to copy the all text from this webpage in a .txt on my Desktop.
The all text must be formatted like in the webpage. I use this with no luck.
HttpClient httpClient = new HttpClient();
File.WriteAllText(@"C:\Users\Matteo\Desktop\google2.txt",
httpClient.GetStringAsync("http://someonewhocares.org/hosts/").Result);
How can I do it?
First of all, you'll need to save your file with a .html
extension. Also, it seems that the webpage uses styles from a separate CSS file: http://someonewhocares.org/pollock.css
You'll need that grab that too to make it look like on the webpage.
Sample code:
HttpClient httpClient = new HttpClient();
File.WriteAllText(@"C:\Users\Matteo\Desktop\index.html",
httpClient.GetStringAsync("http://someonewhocares.org/hosts/").Result);
File.WriteAllText(@"C:\Users\Matteo\Desktop\pollock.css",
httpClient.GetStringAsync("http://someonewhocares.org/pollock.css /").Result);
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.