Web Services : WebClient vs HttpClient vs HttpWebRequest

Using C# I have found multiple ways to retrieve HTML from a given URL.

  • Using  HttpClient / GetByteArrayAsync / WebUtility.HtmlDecode
  • Using HttpClient / GetAsync /ReadAsStringAsync
  • Using   (HttpWebRequest)WebRequest.Create / (HttpWebResponse)request.GetResponse


On top of it,  there is also the HtmlAgilityPack library that lets you load up a web page just by  using the ‘.Load(url)’ method. Check it out here.


For beginners it may be a bit perplexing to see these different libraries. I realized this is because of how new libraries got added.






Sed Usage.

Two pretty useful sed commands:

[1] Show a particular line only

[2] Dealing with range of lines:

[3] Prepend Text to a File at the Command Line

  • sed -i ‘1i id,gender,age’ mldataset.csv  (Prepend Text to a File at the Command Line)

[4] Remove blank lines from file.

  • sed ‘/^$/d’ input.txt > output.txt
  • grep -v ‘^$’ input.txt > output.txt

(Both grep and sed use special pattern ^$ that matchs the blank lines. Grep -v option means print all lines except blank line.)