Я использую парсер HTML Agility Pack в проекте. Я использую скрипт чата PubNub. Я хочу, чтобы моя C # программа принимала сообщения чата и печатала их на этикетке через div id = "box".
Вот код HTML PubNub:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" type="image/png" href="icon.png">
<meta name="description" content="Example of a JavaScript chat app using PubNub JavaScript V4 SDK.">
<meta name="keywords" content="JavaScript,PubNub,Chat,chat-room,chatting,SDK,PubSub-sdk,tutorial">
<meta name="author" content="Chandler Mayo">
<title>JavaScript Chat | PubNub</title>
</head>
<body>
<p><a href="https://www.pubnub.com/?devrel_pbpn=javascript-chat"><img src="https://d2c805weuec6z7.cloudfront.net/Powered_By_PubNub.png" alt="Powered By PubNub" width="150"></a><p>
<p>Enter chat and press enter.</p>
<input id="input" placeholder="Your Message Here"/>
<p>Chat Output:<p>
<div id="box"></div>
<script src="https://cdn.pubnub.com/sdk/javascript/pubnub.4.23.0.min.js"></script>
<script>(function(){
var pubnub = new PubNub({publishKey : 'demo',subscribeKey : 'demo'}); // Your PubNub keys here. Get them from https://dashboard.pubnub.com.
var box = document.getElementById("box"), input = document.getElementById("input"), channel = 'chat';
pubnub.subscribe({channels: [channel]}); // Subscribe to a channel.
pubnub.addListener({message: function(m) {
box.innerHTML = (''+m.message).replace( /[<>]/g, '' ) + '<br>' + box.innerHTML; // Add message to page.
}});
input.addEventListener('keypress', function (e) {
(e.keyCode || e.charCode) === 13 && pubnub.publish({ // Publish new message when enter is pressed.
channel : channel, message : input.value, x : (input.value='')
});
});
})();</script>
</body>
</html>
Мой C# код для получения идентификатора формы div "box":
private void timer1_Tick(object sender, EventArgs e)
{
const string url = "https://javascript-chat.com/";
var web = new HtmlWeb();
var doc = web.Load(url);
string msg = doc.GetElementbyId("box").InnerHtml;
label7.Text = msg.ToString();
}
Но даже когда в чате есть сообщения, на этикетке не печатаются данные. Кто-нибудь может мне помочь?