Я пытаюсь получить простой текст с сайта html, но я получаю html-код вместо обычного текста. Например, < b> привет </b> < p> его me </p> Как я могу преобразовать его в приветствие меня . Любая помощь очень ценится! вот мой код.как конвертировать html в обычный текст C#?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(""https://www.dailyfx.com/real-time-news");
myRequest.Method = "GET";
WebResponse myResponse = myRequest.GetResponse();
StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);
string result = sr.ReadToEnd();
textBox1.Text = result;
sr.Close();
myResponse.Close();
}
}
}
Что вы подразумеваете под Plain Text? –
Просто используйте HtmlAgilityPack, вы можете использовать что-то вроде 'GetString' – Alex
, вам нужно его загрузить или он поставляется со стандартной библиотекой C#? –