私はhtmlウェブサイトからプレーンテキストを取得しようとしていますが、プレーンテキストではなくhtmlコードを取得しています。< b> hello </b> < p> its 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();
}
}
}
プレーンテキストとはどういう意味ですか? –
ちょうどHtmlAgilityPackを使うと、 'GetString'のようなものを使うことができます – Alex
それをダウンロードする必要がありますか、それとも標準のC#ライブラリが付属していますか? –