Ну, вопрос в значительной степени объясняет это. Я знаю, что код очень грязный во время String.equals, но я просто хотел увидеть, понял ли я заголовок ответов. Ясно, что нет, потому что я смотрю в своем браузере и когда добавляется новый вопрос, моя программа никогда не выводит «Да, это изменилось». Почему?Почему этот код не работает для обнаружения обновления страницы?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.IO;
using System.Net;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Uri myUri = new Uri("http://stackoverflow.com/questions?sort=newest");
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(myUri);
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
string org = myHttpWebResponse.Headers.GetValues("Date")[0];
string newone = "";
while (true) //STRICTING FOR TESTING. THIS WOULD BE A Dos ATTACK AS IT NEVER HAS A DELAY BETWEEN REQUESTS.
{
myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
newone = myHttpWebResponse.Headers.GetValues("Date")[0];
if (!newone.Equals(org))
break;
}
Console.WriteLine("Yep it changed");
Console.ReadLine();
}
}
}
Не меняйте мой глупый вопрос. Я попытался удалить мод, чтобы удалить его. – FrostyFire