How to convert website URL page to text TXT in C# .NET Framework
2 min readFeb 10, 2020
Need to extract the text from a website, without all the HTML? Not a problem. Let me demonstrate how to accomplish this in mere minutes using one of our APIs.
First up to the plate, installing our API client. We can get this done via NuGet; just use this command in Package Manager’s console.
Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 2.2.0
Moving right along, we can continue by dropping our input into ConvertWebUrlToTxt:
using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class ConvertWebUrlToTxtExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new ConvertWebApi();var input = new UrlToTextRequest(); // UrlToTextRequest | HTML to Text request parameterstry{// Convert website URL page to text (txt)UrlToTextResponse result = apiInstance.ConvertWebUrlToTxt(input);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling ConvertWebApi.ConvertWebUrlToTxt: " + e.Message );}}}}
Our result will be given as a simple text string .Wow, that was easy, huh? If you liked this rapid fire approach, consider browsing our other API functions, as they can save you a ton of time on related tasks.