public void Run() { // setup HTML document URL var url = "http://www.sukidog.com/jpierre/strings/basics.htm"; // setup CSS selector to select fragments var selector = "p"; IDocumentApi docApi = new HtmlApi(CommonSettings.ClientId, CommonSettings.ClientSecret, CommonSettings.BasePath); // call the SDK method that returns a query result in the response stream. var response = docApi.GetDocumentFragmentByCSSSelectorByUrl(url, selector, "plain"); if (response != null && response.ContentStream != null) { if (response.Status == "NoContent") { Console.WriteLine("Operation succeeded but result is empty"); } else if (response.Status == "OK") { Stream stream = response.ContentStream; string outFile = response.FileName; string outPath = Path.Combine(CommonSettings.OutDirectory, outFile); using (FileStream fstr = new FileStream(outPath, FileMode.Create, FileAccess.Write)) { stream.Position = 0; stream.CopyTo(fstr); fstr.Flush(); Console.WriteLine(string.Format("\nResult file downloaded to: {0}", outPath)); } } } }