How to Convert a URL to Text in C# .NET Core Framework

Cloudmersive
2 min readApr 23, 2024

Using a low-code API, we can quickly and easily pull text from a URL’s HTML content with zero extra hassle.

We can structure our API call using ready-to-run C# code examples provided below. We’ll just need a free Cloudmersive API to authorize our requests, and we’ll be able to make up to 800 URL to TXT conversions per month with zero commitments.

To start, let’s run the below command in our Package Manager console to install the SDK via NuGet:

Install-Package Cloudmersive.APIClient.NETCore.DocumentAndDataConvert -Version 2.2.1

Next, let’s call the function using the below code examples:

using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NETCore.DocumentAndDataConvert.Api;
using Cloudmersive.APIClient.NETCore.DocumentAndDataConvert.Client;
using Cloudmersive.APIClient.NETCore.DocumentAndDataConvert.Model;

namespace Example
{
public class ConvertWebUrlToTxtExample
{
public void main()
{
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");

var apiInstance = new ConvertWebApi();
var input = new UrlToTextRequest(); // UrlToTextRequest | HTML to Text request parameters

try
{
// 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 );
}
}
}
}

We can pass our URL through as a simple string input (like the following JSON example):

{
"Url": "string"
}

That’s all there is to it — now we can easily convert URL pages to text directly with only a few lines of code!

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.