I'm writing a scraper in C# and I'd like to download some data to files and submit some forms. I've been using wget
and curl
so far for that. How would I do that in C# (on Linux)? (I mean a library for that, not calling shell commands via system()
or whatnot).
You can use System.Net.WebClient
, which is the simplest interface for downloading resources in .NET. If you need more control on the requests look at HttpWebRequest
.
For WebClient, just instantiate an instance, and call one of the Download methods which fits your needs:
var cli = new WebClient();
string data = cli.DownloadString("http://www.stackoverflow.com");
WebRequest
is one of the .NET classes for retrieving web content.
A good library to parse the HTML is the HTML Agility Pack that can also directly download the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With