Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Net;
- using System.IO;
- using VkNet;
- using VkNet.Enums.Filters;
- using VkNet.Model.RequestParams;
- namespace Lksh
- {
- class Program
- {
- static WebClient client = new WebClient();
- static VkApi api = new VkApi();
- static string DownloadPage()
- {
- client.Encoding = System.Text.Encoding.UTF8;
- return (new StreamReader(client.OpenRead("http://intellect.lokos.net/sessions/letters.php"),System.Text.Encoding.GetEncoding("windows-1251"))).ReadToEnd();
- }
- static long SendMessage(string message)
- {
- return api.Messages.Send(new MessagesSendParams
- {
- PeerId = 2000000000 + 17,
- Domain = "https2130706433",
- Message = message,
- });
- }
- static void Main(string[] args)
- {
- string login = "+79533647653";
- string password = "Awotxuivamaneparol";
- api.Authorize(new ApiAuthParams
- {
- ApplicationId = 5461330,
- Login = login,
- Password = password,
- Settings = Settings.All
- });
- long id = api.UserId.Value;
- string prev;
- try
- {
- var baf = new StreamReader(@"C:\IntellectParser\buffer.txt");
- prev = baf.ReadToEnd();
- baf.Close();
- }
- catch (FileNotFoundException e)
- {
- prev = DownloadPage();
- Console.WriteLine("Файл буффера не найден! Он будет создан");
- System.IO.File.WriteAllText(@"C:\IntellectParser\buffer.txt", "");
- }
- catch (DirectoryNotFoundException e)
- {
- prev = DownloadPage();
- Console.WriteLine("Директория не найдена!");
- Directory.CreateDirectory(@"c:\IntellectParser");
- System.IO.File.WriteAllText(@"C:\IntellectParser\buffer.txt", "");
- }
- while (true)
- {
- string now = DownloadPage();
- if (now.Length != prev.Length)
- {
- Console.WriteLine("Изменения на сайте Интеллекта");
- SendMessage("Какие-то изменения на сайте Интеллекта");
- prev = now;
- System.IO.File.WriteAllText(@"C:\IntellectParser\buffer.txt", now);
- }
- System.Threading.Thread.Sleep(900000);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement