Пример #1
0
        public async Task Remove(NbPart part)
        {
            var cookie = context.GetCookie(new Url(_bookUrl));
            var url    = $"{_bookUrl}{part.Volume.Id}/{part.Id}/remove";

            WebRequest request = WebRequest.Create(url);

            request.Method = "POST";
            request.Headers[HttpRequestHeader.Cookie] = cookie;
            await request.GetResponseAsync();

            part.Removed = true;
        }
Пример #2
0
        public async Task <List <NbPart> > GetParts(NbVolume vol)
        {
            var parts = new List <NbPart>();

            var document = await GetDocumentAsync(vol.URL);

            while (true)
            {
                foreach (var td in document.QuerySelectorAll("td.o")) // Ячейки с оригинальным текстом
                {
                    var id = ((IHtmlElement)td.Parent).Id;

                    var enEl = td.QuerySelector("p.text");

                    var part = new NbPart
                    {
                        Volume = vol,
                        Id     = id.Substring(1),
                        En     = UnreplaceSpaces(enEl.Text()),
                        Url    = td.QuerySelector("a.ord").GetAttribute("href")
                    };

                    var ruEl = document.QuerySelectorAll($"tr#{id} td.t p.text").LastOrDefault();
                    if (ruEl != null)
                    {
                        part.Tr = UnreplaceSpaces(ruEl.Text());
                    }

                    parts.Add(part);
                }

                var a = document.QuerySelector("#pages-bottom p.n a") as IHtmlAnchorElement;
                if (a == null)
                {
                    break;
                }

                document = await GetDocumentAsync(a.Href);
            }

            return(parts);
        }